JMS text message encoding

I get messages from the jms mq queue which are supposedly utf-8 encoded. However, when reading using msgText = ((TextMessage) msg) .getText (); I get question marks where non-standard characters are present. It seems possible to specify the encoding when using bytemessage, but I cannot find a way to specify the encoding when reading TextMessage. Is there a way to solve this problem, or should I click on messages?

+3
source share
2 answers

We tried adding Dfile.encoding="UTF-8"in Webspherejvm and we added

source = new StreamSource(new ByteArrayInputStream(
     ((TextMessage) msg).getText().getBytes("UTF-8")));

MessageListener. , Dfile.encoding, .

- Websphere , , UTF-8 .

+2

, , utf-8; :

byte[] by = ((TextMessage) msg).getText().getBytes("ISO-8859-1");
String text = new String(by,"UTF-8");
+1

Source: https://habr.com/ru/post/1748510/


All Articles