-
Bug
-
Resolution: Done
-
Major
-
AMQ 7.2.1.GA
-
None
A CORE or CORE-JMS consumer can fail, with an invalid or zero-length message body, in the following circumstances:
1. The message is produced to an anycast destination using an AMQP client
2. The message is consumed from that destination using a CORE or CORE-JMS client
3. The client creates multiple consumers from the same session
4. The consumers consume from the same topic.
The code outline below demonstrates the troublesome client behaviour.
Connection connection = // Create CORE-JMS connection Session session = connection.createSession (false, Session.AUTO_ACKNOWLEDGE); Topic topic1 = session.createTopic (TOPIC1); Topic topic2 = session.createTopic (TOPIC2); MessageConsumer consumer1 = session.createConsumer (topic1); MessageConsumer consumer2 = session.createConsumer (topic2); Message m1 = consumer1.receive(); TextMessage t1 = (TextMessage) m1; // Sometimes fails here with a ClassCastException System.out.println ("got message 1" + t1.getText()); Message m2 = consumer2.receive(); TextMessage t2 = (TextMessage) m2; System.out.println ("got message 2" + t2.getText());
The problem is not 100% reproducible. When it does reproduce, a CORE consumer gets a message with a zero-length body, while a CORE-JMS client gets a BytesMessage of zero length and whose JMSType property is "null", whatever the original message type was.
The problem never reproduces (for me) when using an OpenWire producer and CORE consumer, nor an AMQP producer and AMQP consumer – it seems to be related to the specific conversion of AMQP messages to CORE messages.
Also, the problem never reproduces when the consumers are assigned to different addresses – it seems to be specific to consuming from the same destination with multiple consumers. The code example above is pretty contrived, but the problem reproduces also when the consumers are derived from separate sessions in the same connection, and in different threads (which is a more realistic use of multiple consumers).