You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Timothy Bish (JIRA)" <ji...@apache.org> on 2011/03/07 23:00:59 UTC
[jira] Closed: (AMQ-2644) Encoding problem (latin1) with String
properties on HTTP Transport
[ https://issues.apache.org/jira/browse/AMQ-2644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Timothy Bish closed AMQ-2644.
-----------------------------
Resolution: Cannot Reproduce
Fix Version/s: (was: 5.5.0)
Problem seems to have been fixed in 5.4.2, reopen if you still have issues.
> Encoding problem (latin1) with String properties on HTTP Transport
> ------------------------------------------------------------------
>
> Key: AMQ-2644
> URL: https://issues.apache.org/jira/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 L.
>
> 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.
For more information on JIRA, see: http://www.atlassian.com/software/jira