Class MessagingMessageListenerAdapter
java.lang.Object
org.springframework.jms.listener.adapter.AbstractAdaptableMessageListener
org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter
- All Implemented Interfaces:
jakarta.jms.MessageListener, SessionAwareMessageListener<jakarta.jms.Message>, SubscriptionNameProvider
public class MessagingMessageListenerAdapter
extends AbstractAdaptableMessageListener
implements SubscriptionNameProvider
A
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.
Note that MessagingMessageListenerAdapter implements
SubscriptionNameProvider in order to provide a meaningful default
subscription name. See getSubscriptionName() for details.
- Since:
- 4.1
- Author:
- Stephane Nicoll, Sam Brannen
- See Also:
-
Field Summary
Fields inherited from class AbstractAdaptableMessageListener
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGenerate a subscription name for thisMessageListeneradapter based on the following rules.voidCallback for processing a received JMS message.protected ObjectpreProcessResponse(Object result) Pre-process the given result before it is converted to aMessage.voidsetHandlerMethod(InvocableHandlerMethod handlerMethod) Set theInvocableHandlerMethodto use to invoke the method processing an incomingMessage.protected Message<?> toMessagingMessage(jakarta.jms.Message jmsMessage) Methods inherited from class AbstractAdaptableMessageListener
buildMessage, extractMessage, getDestinationResolver, getMessageConverter, getMessagingMessageConverter, getResponseDestination, getResponseQosSettings, handleListenerException, handleResult, onMessage, postProcessProducer, postProcessResponse, resolveDefaultResponseDestination, sendResponse, setDefaultResponseDestination, setDefaultResponseQueueName, setDefaultResponseTopicName, setDestinationResolver, setHeaderMapper, setMessageConverter, setResponseQosSettings
-
Constructor Details
-
MessagingMessageListenerAdapter
public MessagingMessageListenerAdapter()
-
-
Method Details
-
setHandlerMethod
Set theInvocableHandlerMethodto use to invoke the method processing an incomingMessage. -
onMessage
public void onMessage(jakarta.jms.Message jmsMessage, @Nullable jakarta.jms.Session session) throws jakarta.jms.JMSException Description copied from interface:SessionAwareMessageListenerCallback for processing a received JMS message.Implementors are supposed to process the given Message, typically sending reply messages through the given Session.
- Specified by:
onMessagein interfaceSessionAwareMessageListener<jakarta.jms.Message>- Specified by:
onMessagein classAbstractAdaptableMessageListener- Parameters:
jmsMessage- the received JMS message (nevernull)session- the underlying JMS Session (nevernull)- Throws:
jakarta.jms.JMSException- if thrown by JMS methods
-
toMessagingMessage
-
preProcessResponse
Description copied from class:AbstractAdaptableMessageListenerPre-process the given result before it is converted to aMessage.- Overrides:
preProcessResponsein classAbstractAdaptableMessageListener- Parameters:
result- the result of the invocation- Returns:
- the payload response to handle, either the
resultargument or any other object (for instance wrapping the result).
-
getSubscriptionName
Generate a subscription name for thisMessageListeneradapter based on the following rules.- If the
handlerMethodhas been set, the generated subscription name takes the form ofhandlerMethod.getBeanType().getName() + "." + handlerMethod.getMethod().getName(). - Otherwise, the generated subscription name is the result of invoking
getClass().getName(), which aligns with the default behavior ofAbstractMessageListenerContainer.
- Specified by:
getSubscriptionNamein interfaceSubscriptionNameProvider- Since:
- 5.3.26
- See Also:
- If the
-