0

Using Spring boot 1.5.9 and JMS 2.0.1 with Java 9.0.....

Talking with IBM's MQ (version 9) with their MQQueueConnectionFactory which delivers to an @JmsListener an com.ibm.jms.JMSMessage that extends the javax.jms.Message class. This means the normal type reflection by a MessageConverter isn't used. Not sure where in the Spring JMS pipeline I can transform the JMSMessage into a normal Message and then activate conversion? When testing I would like to use an embedded active mq that produces Message objects not JMSMessage.

Thus it would be great if the annotated receiver method accepted Message not JMSMessage.

Update 1

The following signature has to be used otherwise the Spring pipeline fails with no defined MessageConverter for a IBM JMSMessage:

@JmsListener(destination = "${mq.queue}")
public void receive(
  JMSMessage message,
  @Header(JmsHeaders.MESSAGE_ID) String messageId
) ... {
   ....
}

I want to have a signature that looks like:

@JmsListener(destination = "${mq.queue}")
public void receive(
  Message message,
  @Header(JmsHeaders.MESSAGE_ID) String messageId
) ... {
   ....
}

Otherwise, when testing (with an embedded jms queue manager) the receiving method doesn't have a consistent signature. Must exist a spot in the Spring JMS pipeline (e.g. MessageListener) where I can intercept the JMSMessage, pull out it's delegate Message and send that onto the JmsListener.

Update 2

False alarm. Redid tests with a live configuration and a receive signature that accepts a plain java.jmx.Message and just as M.D. pointed out it worked. As well, the default simple message converter that uses the ClassUtils to turn the underlying JMSTextMessage into a string.

Community
  • 1
  • 1
Matthew Campbell
  • 1,864
  • 3
  • 24
  • 51
  • ActiveMQ will also produce a JMS based message (generally). The JMS listener should also be able to accept a regular `Message` instead of the `javax.jms.Message` and it will do the conversion accordingly. – M. Deinum Jan 09 '18 at 13:27
  • @M.Deinum Problem isn't ActiveMQ rather IBM that passes around it's flavor of the `java.jmx.Message` which is what I would like to catch prior to it hitting the receiver method (and transform the JMSMessage into a Message). – Matthew Campbell Jan 09 '18 at 13:37
  • Your question is unclear on what you want to achieve. You can simply use `Message` as an argument instead of the `javax.jms.Message`. If that doesn't apply to your use-case rewrite your question as it then is unclear what you want to ask. – M. Deinum Jan 09 '18 at 13:52
  • @M.Deinum See update 1. – Matthew Campbell Jan 09 '18 at 13:58
  • 1
    Which `Message` are you using here? As stated as the IBM classes extend the normal JMS interfaces that shouldn't be a problem. – M. Deinum Jan 09 '18 at 14:29
  • @M.Deinum False alarm. But thanks for the help. – Matthew Campbell Jan 09 '18 at 14:50

0 Answers0