[ 
https://issues.apache.org/jira/browse/AMQ-1831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13064463#comment-13064463
 ] 

Angelo Rosenfelder commented on AMQ-1831:
-----------------------------------------

Sorry to resurrect such an old issue, but I think there is a bug in the 
implementation: The JMS Specification Version 1.1 defines the property 
{{JMSXProducerTXID}} of type {{String}}. But the code in ActiveMQ tries to 
parse it as {{int}}:
{{org.apache.activemq.filter.PropertyExpression}}
{noformat}
        JMS_PROPERTY_EXPRESSIONS.put("JMSXProducerTXID", new SubExpression() {

            public Object evaluate(Message message) {
                TransactionId txId = message.getOriginalTransactionId();
                if (txId == null) {
                    txId = message.getTransactionId();
                }
                if (txId == null) {
                    return null;
                }
                return new Integer(txId.toString());
            }
        });
{noformat}

When sending a message for example using HermesJMS, I get a 
NumberFormatException while reading the property {{JMSXProducerTXID}} in my 
client code (code is similar to the original poster's one).

> Message.getStringProperty("JMSXProducerTXID") throws 
> java.lang.NumberFormatException
> ------------------------------------------------------------------------------------
>
>                 Key: AMQ-1831
>                 URL: https://issues.apache.org/jira/browse/AMQ-1831
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.1.0
>         Environment: Windows XP SP2
>            Reporter: Joel Turkel
>             Fix For: 5.3.0
>
>
> A  java.lang.NumberFormatException is thrown when attempting to retrieve the 
> JMSXProducerTXID from a message. The stack trace is:
> Exception in thread "main" java.lang.NumberFormatException: For input string: 
> "TX:ID:JTURKEL-690-4629-1214839585805-0:0:1"
>       at 
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
>       at java.lang.Integer.parseInt(Integer.java:447)
>       at java.lang.Integer.<init>(Integer.java:620)
>       at 
> org.apache.activemq.filter.PropertyExpression$14.evaluate(PropertyExpression.java:147)
>       at 
> org.apache.activemq.filter.PropertyExpression.evaluate(PropertyExpression.java:194)
>       at 
> org.apache.activemq.command.ActiveMQMessage.getObjectProperty(ActiveMQMessage.java:447)
>       at 
> org.apache.activemq.command.ActiveMQMessage.getStringProperty(ActiveMQMessage.java:535)
>       at com.queue.test.MQTest.testBug(MQTest.java:41)
>       at com.queue.test.ActiveMQTest.main(ActiveMQTest.java:21)
> Here is some simple test code to reproduce the problem:
>               ConnectionFactory connectionFactory = new 
> ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_USER, 
>                               ActiveMQConnection.DEFAULT_PASSWORD, 
> ActiveMQConnection.DEFAULT_BROKER_URL)
>               Connection connection = connectionFactory.createConnection();   
>         
>               connection.start();
>               Session producerSession = connection.createSession(true, 
> Session.SESSION_TRANSACTED);
>               MessageProducer producer = 
> producerSession.createProducer(producerSession.createQueue("myQueue"));
>               TextMessage producerMessage = 
> producerSession.createTextMessage("Test Message");
>               producer.send(producerMessage);
>               producer.close();
>               producerSession.commit();
>               producerSession.close();
>               
>               Session consumerSession = connection.createSession(true, 
> Session.SESSION_TRANSACTED);
>               MessageConsumer consumer = 
> consumerSession.createConsumer(consumerSession.createQueue("myQueue"));
>               Message consumerMessage = consumer.receive(1000);
>               
> System.out.println(consumerMessage.getStringProperty("JMSXProducerTXID"));
>               consumer.close();
>               consumerSession.commit();
>               consumerSession.close();
>               connection.close();
> This problem is quite severe for us since we need the transaction id property 
> and would like to certify against ActiveMQ.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to