public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageListener implements SubscriptionNameProvider
MessageListener adapter that invokes a configurable
InvocableHandlerMethod.
Wraps the incoming Message in Spring's Message
abstraction, copying the JMS standard headers using a configurable
JmsHeaderMapper.
The original Message and the Session
are provided as additional arguments so that these can be injected as
method arguments if necessary.
As of Spring Framework 5.3.26, MessagingMessageListenerAdapter implements
SubscriptionNameProvider in order to provide a meaningful default
subscription name. See getSubscriptionName() for details.
Message,
JmsHeaderMapper,
InvocableHandlerMethodlogger| Constructor and Description |
|---|
MessagingMessageListenerAdapter() |
| Modifier and Type | Method and Description |
|---|---|
String |
getSubscriptionName()
Generate a subscription name for this
MessageListener adapter based
on the following rules. |
void |
onMessage(Message jmsMessage,
Session session)
Callback for processing a received JMS message.
|
protected Object |
preProcessResponse(Object result)
Pre-process the given result before it is converted to a
Message. |
void |
setHandlerMethod(InvocableHandlerMethod handlerMethod)
Set the
InvocableHandlerMethod to use to invoke the method
processing an incoming Message. |
protected Message<?> |
toMessagingMessage(Message jmsMessage) |
buildMessage, extractMessage, getDestinationResolver, getMessageConverter, getMessagingMessageConverter, getResponseDestination, getResponseQosSettings, handleListenerException, handleResult, onMessage, postProcessProducer, postProcessResponse, resolveDefaultResponseDestination, sendResponse, setDefaultResponseDestination, setDefaultResponseQueueName, setDefaultResponseTopicName, setDestinationResolver, setHeaderMapper, setMessageConverter, setResponseQosSettingspublic void setHandlerMethod(InvocableHandlerMethod handlerMethod)
InvocableHandlerMethod to use to invoke the method
processing an incoming Message.public void onMessage(Message jmsMessage, @Nullable Session session) throws JMSException
SessionAwareMessageListenerImplementors are supposed to process the given Message, typically sending reply messages through the given Session.
onMessage in interface SessionAwareMessageListener<Message>onMessage in class AbstractAdaptableMessageListenerjmsMessage - the received JMS message (never null)session - the underlying JMS Session (never null)JMSException - if thrown by JMS methodsprotected Object preProcessResponse(Object result)
AbstractAdaptableMessageListenerMessage.preProcessResponse in class AbstractAdaptableMessageListenerresult - the result of the invocationresult argument
or any other object (for instance wrapping the result).public String getSubscriptionName()
MessageListener adapter based
on the following rules.
handlerMethod
has been set, the generated subscription name takes the form of
handlerMethod.getBeanType().getName() + "." + handlerMethod.getMethod().getName().getClass().getName(), which aligns with the default behavior of
AbstractMessageListenerContainer.getSubscriptionName in interface SubscriptionNameProviderSubscriptionNameProvider.getSubscriptionName()