admin 管理员组文章数量: 1086019
have a string "X°XX" which RabbitMQ writes out as "X?XX"
I understand that this happens, when you stream a string into bytes with one charset UTF-8. And write the bytes back to a string using another charset such as US_ASCII.
I am using Camel to set up the message and route
from(requestUrl)
.routeId(JourneyConstants.BACKEND_ROUTE_ID)
.routeProperty(CommonConstants.ROUTE_TYPE, RouteIdGenerator.RouteType.AMQP_CONSUMER.name())
.log(JourneyConstants.BACKEND_ROUTE_ID +" Received, payload ${body} and headers, ${headers}")
.removeHeader(JourneyConstants.CONTENT_LENGTH) // Due to a new ISTIO we had to remove the content length header
.setExchangePattern(ExchangePattern.InOnly)
.setHeader(CommonConstants.JOURNEY_NAME, constant(JourneyConstants.JOURNEY_NAME_VALUE))
.setHeader(Exchange.CONTENT_TYPE, constant("application/json;charset=utf-8"))
.convertBodyTo(String.class)
.setProperty(CommonConstants.ORIGINAL_MESSAGE, body())
.setProperty(CommonConstants.BACKEND_URL, constant(backendUrl))
.setProperty(CommonConstants.FAILURE_QUEUE_URL, constant(queueUrls))
.setProperty(CommonConstants.CODES_TRANSIENT_QUEUE, constant("50[0-9]|40[1,3,4,8]"))
.setProperty(CommonConstants.CODES_PERSISTENT_QUEUE, constant("4[0,2,5,6,7,9]"))
.convertBodyTo(String.class)
.setHeader(CommonConstants.USE_HEADER_STRATEGY,constant("true"))
.setHeader(CommonConstants.HMRC_ASSETS_OPERATION_TYPE, constant(CommonConstants.VALIDATION_JSON))
.toD(assetEndpointUrl)
So we have
.setHeader(Exchange.CONTENT_TYPE, constant("application/json;charset=utf-8"))
and
.convertBodyTo(String.class)
But since I have still getting the charector ?. Do I need To set a setProperty to make sure that convertBodyTo(String.class) uses charset=utf-8
Thank you for any help
本文标签:
版权声明:本文标题:java - Apache Camel, RabbitMQ, special character is transforrmed into a Question Mark - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1738407425a1974935.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论