You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by RuralHunter <ru...@gmail.com> on 2011/03/07 17:46:44 UTC

Character encoding problem of the messages in queue

Hi, I'm using Activemq 5.4.2 on Ubuntu server.
I put text message with java by these codes:
TextMessage message = session.createTextMessage(myText);
        producer.send(message);
        myLogger.finest("Sent message:");
        myLogger.finest(message.getText());

"myText" contains some Chinese characters. and I can see characters are
correct in the log output above. But when I get the message from either
another java program or by the web admin console, I can see the Chinese
characters become "????". I guess some character encoding transformation
happened when the messages put into the queue. What should I do to make the
Chinese characters correct in the queue? Is there a charset/encoding
parameter I can set for the broker or queue or maybe the JVM?

btw, I used to use 5.4.x(some old version) before on windows and didn't see
this problem.

--
View this message in context: http://activemq.2283324.n4.nabble.com/Character-encoding-problem-of-the-messages-in-queue-tp3339428p3339428.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Character encoding problem of the messages in queue

Posted by RuralHunter <ru...@gmail.com>.
All right looks I'm stupid. this thread can be discarded. This is not an
Activemq problem but just the output problem of my receive end. The web
admin console displays bad characters but that's just fine. It just doesn't
show them correctly but the message in it is correct.

--
View this message in context: http://activemq.2283324.n4.nabble.com/Character-encoding-problem-of-the-messages-in-queue-tp3339428p3340439.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Character encoding problem of the messages in queue

Posted by Gary Tully <ga...@gmail.com>.
Text is encoded in utf-8, your call to getText() below is the
unmarshaled state as the original message is copied on send.
see the source here:
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQTextMessage.java?revision=1074725&view=markup

If you need utf-16, you will need to use a bytes message.

On 7 March 2011 16:46, RuralHunter <ru...@gmail.com> wrote:
> Hi, I'm using Activemq 5.4.2 on Ubuntu server.
> I put text message with java by these codes:
> TextMessage message = session.createTextMessage(myText);
>        producer.send(message);
>        myLogger.finest("Sent message:");
>        myLogger.finest(message.getText());
>
> "myText" contains some Chinese characters. and I can see characters are
> correct in the log output above. But when I get the message from either
> another java program or by the web admin console, I can see the Chinese
> characters become "????". I guess some character encoding transformation
> happened when the messages put into the queue. What should I do to make the
> Chinese characters correct in the queue? Is there a charset/encoding
> parameter I can set for the broker or queue or maybe the JVM?
>
> btw, I used to use 5.4.x(some old version) before on windows and didn't see
> this problem.
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Character-encoding-problem-of-the-messages-in-queue-tp3339428p3339428.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
http://blog.garytully.com
http://fusesource.com