AMQP producer based persistant messages are not being dequeued by a consumer
Issue
- I ran a simple test with an AMQP based message producer sending JMS TextMessages to a persistent queue. It looks like internally the messages are persisted as ByteMessages.
Without the broker being restarted, a consumer is able to pull the messages as TextMessages.
However, when the broker is restarted with pending messages in the queue, subsequent attempts by a consumer to read the messages off the queue fail with the below exception on the server side.
javax.jms.MessageNotReadableException: Message body is write-only
at org.apache.activemq.command.ActiveMQBytesMessage.checkWriteOnlyBody(ActiveMQBytesMessage.java:863)
at org.apache.activemq.command.ActiveMQBytesMessage.initializeReading(ActiveMQBytesMessage.java:868)
at org.apache.activemq.command.ActiveMQBytesMessage.getBodyLength(ActiveMQBytesMessage.java:190)
at org.apache.qpid.proton.jms.AMQPNativeOutboundTransformer.transform(AMQPNativeOutboundTransformer.java:63)
at org.apache.qpid.proton.jms.AutoOutboundTransformer.transform(AutoOutboundTransformer.java:37)
at org.apache.activemq.transport.amqp.AmqpProtocolConverter$ConsumerContext.pumpOutbound(AmqpProtocolConverter.j
ava:751)
On the client side, the below exception is seen.
java.lang.ClassCastException: org.apache.activemq.command.ActiveMQBytesMessage cannot be cast to javax.jms.TextMessage
at com.aaa.consumer.MyListener.onMessage(MyListener.java:29)
at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1321)
Environment
- JBoss A-MQ
- 6.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
