activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antoine Libert (JIRA)" <j...@apache.org>
Subject [jira] Created: (AMQ-2644) Encoding problem (latin1) with String properties on HTTP Transport
Date Tue, 09 Mar 2010 17:01:44 GMT
Encoding problem (latin1) with String properties on HTTP Transport
------------------------------------------------------------------

                 Key: AMQ-2644
                 URL: https://issues.apache.org/activemq/browse/AMQ-2644
             Project: ActiveMQ
          Issue Type: Bug
          Components: Connector
    Affects Versions: 5.3.0
         Environment: ActiveMQ 5.3.0 win32 RELEASE
ActiveMQ 5.3.0 linux-x64 RELEASE

activemq-all-5.3.0.jar
commons-httpclient-3.1.jar
xmlpull-1.1.3.4d_b4_min.jar
xstream-1.3.jar
            Reporter: Antoine Libert


When attaching a String property to a Message sent on HTTP transport, the consumer gets a
latin1 encoded String instead of a UTF-8 String.

Basic scheme :

(producer) message.setStringProperty("Test", "éèçàù") => HTTP(s) Transport => Broker
=> TCP Transport => (consumer) message.getStringProperty("Test")

Result : éèçàù (garbage).

Workaround :

new String(message.getStringProperty("Test").getBytes("ISO-8859-1"))

Simple test case :

import javax.jms.Connection;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;

import org.apache.activemq.ActiveMQConnectionFactory;

public static void main(String[] args) throws Exception {

        String testString = "éèçàù";

        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("https://localhost:8443");
        Connection connection = connectionFactory.createConnection();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(session.createQueue("TEST"));
        connection.start();

        Message message = session.createMessage();
        message.setStringProperty("Test", testString);
        System.out.println("Original string : " + testString);
        producer.send(message);

        connection.close();

        connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:9292");
        connection = connectionFactory.createConnection();
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageConsumer consumer = session.createConsumer(session.createQueue("TEST"));
        connection.start();

        while (true) {
            Message messageReceiver = consumer.receive();

            System.out.println("Result string : " + messageReceiver.getStringProperty("Test"));
            System.out.println("Result string (forced UTF8) : " + new String(messageReceiver.getStringProperty("Test").getBytes("UTF-8")));
            System.out
                    .println("Result string (forced ISO-8859-1) : " + new String(messageReceiver.getStringProperty("Test").getBytes("ISO-8859-1")));

        }
}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message