Bug 705015 - Message.setJMSMessageID() not compatible with ActiveMQ MessageID
Summary: Message.setJMSMessageID() not compatible with ActiveMQ MessageID
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: qpid-java
Version: 2.2
Hardware: All
OS: Linux
high
medium
Target Milestone: 3.0
: ---
Assignee: Rajith Attapattu
QA Contact: Michal Toth
URL:
Whiteboard:
Depends On:
Blocks: 785156 952750
TreeView+ depends on / blocked
 
Reported: 2011-05-16 12:17 UTC by Siddhesh Poyarekar
Modified: 2018-12-06 14:38 UTC (History)
13 users (show)

Fixed In Version: qpid-java-0.22-1.el5, qpid-java-0.22-2.el6
Doc Type: Bug Fix
Doc Text:
It was discovered that the message implementation did not allow a non-UUID string to be set as the message ID. When a Qpid JMS message was sent through a third-party message provider, setting the message-id resulted in an exception if the message-id was not a valid UUID. The fix now allows any string to be set as the message ID. When sending the message through the Qpid JMS producer, it is set as a UUID (as per the JMS spec and AMQP spec).
Clone Of:
: 952750 (view as bug list)
Environment:
Last Closed: 2014-09-24 15:02:50 UTC
Target Upstream Version:


Attachments (Terms of Use)
activemq.xml (3.38 KB, text/xml)
2011-05-16 12:17 UTC, Siddhesh Poyarekar
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Apache JIRA QPID-3272 0 None None None 2012-11-05 16:47:22 UTC
Red Hat Product Errata RHEA-2014:1296 0 normal SHIPPED_LIVE Red Hat Enterprise MRG Messaging 3.0 Release 2014-09-24 19:00:06 UTC

Description Siddhesh Poyarekar 2011-05-16 12:17:05 UTC
Created attachment 499124 [details]
activemq.xml

Description of problem:
setJMSMessageID() in the qpid java client validates that the messageid string is a UUID. This conflicts with the MessageID generation of ActiveMQ, which makes a message id out of the producer id (queue/exchange name) and a sequence number.

The JMS specification does not seem to have a requirement for the MessageID to be a UUID. The only requirements are that it be preceded by an 'ID:' and be unique within a provider.

Version-Release number of selected component (if applicable):
qpid-java-client-0.7.946106-15.el5

How reproducible:
Always

Steps to Reproduce:
1. Set up a JMS to JMS bridge between qpid and ActiveMQ using attached activemq.xml (copy into $ACTIVEMQ_DIR/conf/)
2. Start qpidd and activemq ($ACTIVEMQ_DIR/bin/activemq console)
3. Send a message to jms2jmsQ
  
Actual results:

ActiveMQ reply fails with the following exception:

ERROR | failed to forward message on attempt: 1 reason: javax.jms.JMSException: MessageId 'ID:dhcp209-12.gsslab.pnq.redhat.com-45266-1305237148981-3:0:3:1:1' is not of the correct format, it must be ID: followed by a UUID message: Body:

JMS Correlation ID: null
JMS timestamp: 1305237163052
JMS expiration: 0
JMS priority: 4
JMS delivery mode: 2
JMS reply to: null
JMS Redelivered: false
JMS Destination: queue://jms2jmsQ
JMS Type: null
JMS MessageID: ID:96ebf863-b620-3932-86cc-860cc4e43bd0
JMS Content-Type: text/plain
AMQ message number: 2
Properties:<NONE>
javax.jms.JMSException: MessageId 'ID:dhcp209-12.gsslab.pnq.redhat.com-45266-1305237148981-3:0:3:1:1' is not of the correct format, it must be ID: followed by a UUID
	at org.apache.qpid.client.message.AMQMessageDelegate_0_10.setJMSMessageID(AMQMessageDelegate_0_10.java:165)
	at org.apache.qpid.client.message.AbstractJMSMessage.setJMSMessageID(AbstractJMSMessage.java:92)
	at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1727)
	at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:231)
	at org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:300)
	at org.apache.activemq.ActiveMQQueueSender.send(ActiveMQQueueSender.java:111)
	at org.apache.activemq.network.jms.QueueBridge.sendMessage(QueueBridge.java:80)
	at org.apache.activemq.network.jms.DestinationBridge.onMessage(DestinationBridge.java:129)
	at org.apache.qpid.client.BasicMessageConsumer.notifyMessage(BasicMessageConsumer.java:722)
	at org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:185)
	at org.apache.qpid.client.BasicMessageConsumer.notifyMessage(BasicMessageConsumer.java:696)
	at org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:207)
	at org.apache.qpid.client.BasicMessageConsumer_0_10.notifyMessage(BasicMessageConsumer_0_10.java:44)
	at org.apache.qpid.client.AMQSession$Dispatcher.notifyConsumer(AMQSession.java:3193)
	at org.apache.qpid.client.AMQSession$Dispatcher.dispatchMessage(AMQSession.java:3137)
	at org.apache.qpid.client.AMQSession$Dispatcher.access$900(AMQSession.java:2918)
	at org.apache.qpid.client.AMQSession.dispatch(AMQSession.java:2911)
	at org.apache.qpid.client.message.UnprocessedMessage.dispatch(UnprocessedMessage.java:55)
	at org.apache.qpid.client.AMQSession$Dispatcher.run(AMQSession.java:3065)
	at java.lang.Thread.run(Thread.java:662)


Expected results:

ActiveMQ sends a reply successfully

Additional info:

The core behaviour of validating a UUID can also be seen with a standalone program that calls a Message.setJMSMessageID(foo) where foo is not a UUID.

Comment 1 Rajith Attapattu 2011-05-16 19:38:31 UTC
The JMS spec mentions the following for the getMessageID() method,

"When a message is sent, JMSMessageID can be ignored. When the send or publish method returns, it contains a provider-assigned value. "

Therefore, technically a JMS provider is within it's right to ignore any previously set value and set it's own ID.

It also says the following for the setMessageID() method,

"JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received."

However it's not quite clearly what should be the behaviour if a received message is being resent after resetting the message id.

On the other hand the AMQP spec request all messages to have a unique identifier, hence the reason why we have a validation there.

"Message-id is an optional property of UUID type which uniquely identifies a message within the message system."

I would be discussing this issue in upstream Qpid project to figure out possible solutions to address this issue and will update the ticket accordingly.

Comment 2 Siddhesh Poyarekar 2011-06-02 14:16:29 UTC
There seem to be similar problems with jboss and qpid connectivity as well. I haven't tried it myself yet.

Comment 3 ranjith ruban 2012-11-05 06:58:45 UTC
Hello 

Is there any update on this issue. 

Regards
Ranjith Ruban

Comment 4 Pavel Moravec 2012-11-05 16:47:00 UTC
The same problem appears with WebsphereMQ, backtrace:

root IPE_NOHIT: javax.jms.JMSException: MessageId
'ID:414d5120495045344445563420202020aa4085502c747620' is not of the correct
format, it must be ID: followed by a UUID
        at 
org.apache.qpid.client.message.AMQMessageDelegate_0_10.setJMSMessageID(AMQMe
ssageDelegate_0_10.java:194)
        at 
org.apache.qpid.client.message.AbstractJMSMessage.setJMSMessageID(AbstractJM
SMessage.java:63)
        at 
com.ibm.mq.jms.MQJMSMessage.setHeaderFromMQMD(MQJMSMessage.java:932)
        at 
com.ibm.mq.jms.MQMessageProducer.sendInternal(MQMessageProducer.java:1813)
        at 
com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1139)
..

Comment 5 Rajith Attapattu 2013-01-16 21:52:08 UTC
I have proposed a solution upstream, Once we reach some consensus around the issue I plan to implement the solution (or an alternative).

Comment 6 Rajith Attapattu 2013-02-04 21:15:44 UTC
A fix has been committed upstream at http://svn.apache.org/viewvc?rev=1442364&view=rev

This issue is tracked via QPID-4566

Comment 7 Zdenek Kraus 2013-02-26 14:42:28 UTC
I tried to start up an ActiveMQ with attached 'activemq.xml' and it fails with configuration errors:

ERROR | Failed to load: class path resource [activemq.xml], reason: Line 34 in XML document from class path resource [activemq.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 34; columnNumber: 160; cvc-complex-type.3.2.2: Attribute 'destroyApplicationContextOnStop' is not allowed to appear in element 'broker'.
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 34 in XML document from class path resource [activemq.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 34; columnNumber: 160; cvc-complex-type.3.2.2: Attribute 'destroyApplicationContextOnStop' is not allowed to appear in element 'broker'.
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
	at org.apache.xbean.spring.context.ResourceXmlApplicationContext.loadBeanDefinitions(ResourceXmlApplicationContext.java:111)
	at org.apache.xbean.spring.context.ResourceXmlApplicationContext.loadBeanDefinitions(ResourceXmlApplicationContext.java:104)
	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:530)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:444)
	at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:64)
	at org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:52)
	at org.apache.activemq.xbean.XBeanBrokerFactory$1.<init>(XBeanBrokerFactory.java:101)
	at org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:101)
	at org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:65)
	at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)
	at org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)
	at org.apache.activemq.console.command.StartCommand.startBroker(StartCommand.java:125)
	at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:84)
	at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
	at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:150)
	at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
	at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:104)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.apache.activemq.console.Main.runTaskClass(Main.java:262)
	at org.apache.activemq.console.Main.main(Main.java:115)
Caused by: org.xml.sax.SAXParseException; lineNumber: 34; columnNumber: 160; cvc-complex-type.3.2.2: Attribute 'destroyApplicationContextOnStop' is not allowed to appear in element 'broker'.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:387)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:321)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:421)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3186)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(XMLSchemaValidator.java:2663)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2070)
	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:709)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:376)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2732)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:819)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:748)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:239)
	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:288)
	at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
	... 26 more


When I try to start ActiveMQ with original 'activemq.xml' it starts correctly without errors. I'm using last ActiveMQ 5.8 from http://activemq.apache.org/activemq-580-release.html

Could you please update the activemq.xml to final version of ActiveMQ?

Raising NEEDINFO

Comment 9 Zdenek Kraus 2013-03-08 05:12:17 UTC
Rajith since you didn't answer me, I reraising needinfo, please see Comment 7

Comment 10 Michal Toth 2013-04-25 13:46:37 UTC
We've found that parameter "destroyApplicationContextOnStop" is obsolete in latest reference http://activemq.apache.org/xml-reference.html .
By omitting it we moved to another error, which we can't solve.


ERROR | Failed to load: class path resource [activemq.xml], reason: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in class path resource [activemq.xml]: Cannot create inner bean 'jmsQueueConnector#608314f2' of type [org.apache.activemq.network.jms.JmsQueueConnector] while setting bean property 'jmsBridgeConnectors' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsQueueConnector#608314f2' defined in class path resource [activemq.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.springframework.jndi.JndiTemplate' to required type 'org.apache.activemq.network.jms.JndiLookupFactory' for property 'jndiOutboundTemplate'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.jndi.JndiTemplate] to required type [org.apache.activemq.network.jms.JndiLookupFactory] for property 'jndiOutboundTemplate': no matching editors or conversion strategy found
...

Please advice.

Comment 11 Rajith Attapattu 2013-04-25 14:03:26 UTC
Steps to reproduce.

(Just using Qpid)

1. Create a message, set any string as message-id, observe no exception is thrown.

2. Then receive it and try to set any string as message-id and observe that no exception is thrown.


(Using Qpid and ActiveMQ)

1. Send a message to using Qpid.
2. Create an app that receives the message from Qpid and then sends it using ActiveMQ.
3. Observe no exception is being thrown in step 2.

Comment 12 Rajith Attapattu 2013-04-25 14:08:10 UTC
Zdenek,

I don't know about ActiveMQ. I didn't use it to verify the fix.

Regards,

Rajith

Comment 13 Michal Toth 2013-04-26 09:08:47 UTC
Reproducing  

(Just using Qpid)

1. Create a message, set any string as message-id, observe no exception is thrown.
2. Then receive it and try to set any string as message-id and observe that no exception is thrown.
---

Received error:
javax.jms.JMSException: MessageId 'ThisIsMyID' is not of the correct format, it must be ID: followed by a UUID
	at org.apache.qpid.client.message.AMQMessageDelegate_0_10.setJMSMessageID(AMQMessageDelegate_0_10.java:199)
	at org.apache.qpid.client.message.AbstractJMSMessage.setJMSMessageID(AbstractJMSMessage.java:63)
	at org.apache.qpid.example.Hello.runTest(Hello.java:63)
	at org.apache.qpid.example.Hello.main(Hello.java:40)


JMSMessageID strings we've tried:
"ThisIsMyID"
"ID:ThisIsMyID"

Both with same result


Packages:
qpid-cpp-server-0.18-14.el6.x86_64
qpid-java-client-0.18-7.el6.noarch

Comment 14 Michal Toth 2013-06-20 13:14:25 UTC
Verified and fixed. No more JMSExpcetion complain about MessageId format.

Packages:
RHEL6
qpid-cpp-server-0.22-4
qpid-java-client-0.22-3.el6.noarch

RHEL 5
qpid-cpp-server-0.22-4
qpid-java-client-0.22-2.el5.noarch

Comment 16 Rajith Attapattu 2013-09-24 15:11:20 UTC
The new client use the same solution used for the old client to handle this issue.
You use the same steps mentioned in comment#11 to verify the issue.

Note: Please make sure you are using the new client and not the old one.

Comment 17 Rajith Attapattu 2013-09-24 15:11:53 UTC
The new client uses the same solution as the old one.

You could use the same steps as mentioned in comment #11 to verify it.
Please make sure you are using the new client instead of the old one.

Comment 18 Justin Ross 2013-09-30 12:55:57 UTC
Rajith, the should be getting the new client by default, true?

(In reply to Rajith Attapattu from comment #17)
> The new client uses the same solution as the old one.
> 
> You could use the same steps as mentioned in comment #11 to verify it.
> Please make sure you are using the new client instead of the old one.

Comment 20 Rajith Attapattu 2014-02-10 14:46:48 UTC
Replying to clear the needinfo flag. We don't have a new client anymore.

Comment 22 errata-xmlrpc 2014-09-24 15:02:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2014-1296.html


Note You need to log in before you can comment on or make changes to this bug.