qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Branden Smith <BSm...@liaison.com>
Subject AMQP-JMS client: messages dequeued as AmqpMessageImpl instances?
Date Fri, 11 Oct 2013 21:21:56 GMT
I'm using the Qpid AMQP-JMS client to both publish and subscribe to the same queue (provided
by HornetQ 2.4.0.beta1); I'm publishing a message as a javax.jms.TextMessage, but it is being
received by the listener as a org.apache.qpid.amqp_1_0.jms.impl.AmqpMessageImpl.

Publisher:

    queueSession = queueCnxn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    queueProducer = queueSession.createSender(eventQueue);
    queueProducer.send(queueSession.createTextMessage("test message"));

Consumer:

    public class TestConsumer implements MessageListener {
	@Override
	public void onMessage(Message message) {
		final String logPrefix;
		TextMessage txtMsg;
		
		logPrefix = "[onMessage] ";
		log.debug(">>> " + logPrefix);
		
		try {
			message.acknowledge();
			log.debug("message acknowledged");
			log.debug("message type: " + message.getClass());
			//log.debug("body assignable to String??? " + message.isBodyAssignableTo(String.class));
		} catch (JMSException jmsExc) {
			// TODO
			log.error("ack-exception!", jmsExc);
		}
      ...

Output:

    17:07:42.035 [Thread-4] DEBUG >>> [onMessage] 
    17:07:42.035 [Thread-4] DEBUG message acknowledged
    17:07:42.035 [Thread-4] DEBUG message type: class org.apache.qpid.amqp_1_0.jms.impl.AmqpMessageImpl

I'm not sure what to do with AmqpMessageImpl; it only inherits from MessageImpl, and only
implements javax.jms.Message. Furthermore, if I attempt to call Message.isBodyAssignableTo(Class<T>),
I get an AbstractMethodError. Trying to directly cast to TextMessage throws a ClassCastException.

The examples all show the consumer receiving the usual types defined by the JMS API; any thoughts
as to what I could be doing wrong?

Thanks,

Branden Smith
bsmith@liaison.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Mime
View raw message