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

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)