The DefaultMessageListenerContainer
class in spring JMS has the setter method
setMessageConverter(...)
which allows to supply any converter we want.
For an annotated message listener, this makes sense as we can directly define
@JmsListener(destination = "myDestination")
public void processOrder(MyConvertedType data) { ... }
and spring will take care of converting and passing the message to this listener.
So, this clearly makes sense for an annotated listener. My question is, is setting a message converter useful for non-annotated message listeners? Something like
public void registerListener(String queueName, MessageListener listener) {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setMessageConverter(getMessageConverter());
container.setDestinationName(queueName);
container.setMessageListener(listener);
container.initialize();
container.start();
}
From my search in the docs/javadocs and the limited understanding of source code, I think that setting a message converter for this case is not helpful, i.e. message conversion will not handled by spring. The conversion has to be handled in the passed MessageListener callback? Correct me if I am wrong.