You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Antoine Libert (JIRA)" <ji...@apache.org> on 2010/03/09 18:01:44 UTC

[jira] Created: (AMQ-2644) Encoding problem (latin1) with String properties on HTTP Transport

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.


[jira] Commented: (AMQ-2644) Encoding problem (latin1) with String properties on HTTP Transport

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/AMQ-2644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58185#action_58185 ] 

Timothy Bish commented on AMQ-2644:
-----------------------------------

Can you try this with the 5.4 SNAPSHOT build?  It should be fixed there.

> 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.


[jira] Updated: (AMQ-2644) Encoding problem (latin1) with String properties on HTTP Transport

Posted by "Bruce Snyder (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/AMQ-2644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Snyder updated AMQ-2644:
------------------------------

    Fix Version/s: 5.5.0
                       (was: 5.4.1)

> 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
>             Fix For: 5.5.0
>
>
> 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.