Search in sources :

Example 26 with MessagingMessageListenerAdapter

use of org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter in project spring-framework by spring-projects.

the class MethodJmsListenerEndpoint method createMessageListener.

@Override
protected MessagingMessageListenerAdapter createMessageListener(MessageListenerContainer container) {
    Assert.state(this.messageHandlerMethodFactory != null, "Could not create message listener - MessageHandlerMethodFactory not set");
    MessagingMessageListenerAdapter messageListener = createMessageListenerInstance();
    Object bean = getBean();
    Method method = getMethod();
    Assert.state(bean != null && method != null, "No bean+method set on endpoint");
    InvocableHandlerMethod invocableHandlerMethod = this.messageHandlerMethodFactory.createInvocableHandlerMethod(bean, method);
    messageListener.setHandlerMethod(invocableHandlerMethod);
    String responseDestination = getDefaultResponseDestination();
    if (StringUtils.hasText(responseDestination)) {
        if (container.isReplyPubSubDomain()) {
            messageListener.setDefaultResponseTopicName(responseDestination);
        } else {
            messageListener.setDefaultResponseQueueName(responseDestination);
        }
    }
    QosSettings responseQosSettings = container.getReplyQosSettings();
    if (responseQosSettings != null) {
        messageListener.setResponseQosSettings(responseQosSettings);
    }
    MessageConverter messageConverter = container.getMessageConverter();
    if (messageConverter != null) {
        messageListener.setMessageConverter(messageConverter);
    }
    DestinationResolver destinationResolver = container.getDestinationResolver();
    if (destinationResolver != null) {
        messageListener.setDestinationResolver(destinationResolver);
    }
    return messageListener;
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) DestinationResolver(org.springframework.jms.support.destination.DestinationResolver) InvocableHandlerMethod(org.springframework.messaging.handler.invocation.InvocableHandlerMethod) QosSettings(org.springframework.jms.support.QosSettings) InvocableHandlerMethod(org.springframework.messaging.handler.invocation.InvocableHandlerMethod) Method(java.lang.reflect.Method) MessageConverter(org.springframework.jms.support.converter.MessageConverter)

Aggregations

MessagingMessageListenerAdapter (org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter)26 Test (org.junit.jupiter.api.Test)24 Session (jakarta.jms.Session)17 StubTextMessage (org.springframework.jms.StubTextMessage)9 SimpleMessageListenerContainer (org.springframework.jms.listener.SimpleMessageListenerContainer)7 Method (java.lang.reflect.Method)3 TextMessage (jakarta.jms.TextMessage)2 ListenerExecutionFailedException (org.springframework.jms.listener.adapter.ListenerExecutionFailedException)2 QosSettings (org.springframework.jms.support.QosSettings)2 MessageConverter (org.springframework.jms.support.converter.MessageConverter)2 DestinationResolver (org.springframework.jms.support.destination.DestinationResolver)2 DefaultMessageHandlerMethodFactory (org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory)2 Destination (jakarta.jms.Destination)1 ObjectMessage (jakarta.jms.ObjectMessage)1 QueueSender (jakarta.jms.QueueSender)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 JmsListenerContainerTestFactory (org.springframework.jms.config.JmsListenerContainerTestFactory)1 MethodJmsListenerEndpoint (org.springframework.jms.config.MethodJmsListenerEndpoint)1 MessageConversionException (org.springframework.messaging.converter.MessageConversionException)1 InvocableHandlerMethod (org.springframework.messaging.handler.invocation.InvocableHandlerMethod)1