Search in sources :

Example 16 with MessagingMessageListenerAdapter

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

the class MethodJmsListenerEndpointTests method processAndReplyWithSendToTopic.

@Test
public void processAndReplyWithSendToTopic() throws JMSException {
    String methodName = "processAndReplyWithSendTo";
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setPubSubDomain(true);
    MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container);
    processAndReplyWithSendTo(listener, "replyDestination", true);
    assertListenerMethodInvocation(sample, methodName);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.Test)

Example 17 with MessagingMessageListenerAdapter

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

the class MethodJmsListenerEndpointTests method resolveHeaders.

@Test
public void resolveHeaders() throws JMSException {
    MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, Map.class);
    Session session = mock(Session.class);
    StubTextMessage message = createSimpleJmsTextMessage("my payload");
    message.setIntProperty("customInt", 1234);
    message.setJMSMessageID("abcd-1234");
    listener.onMessage(message, session);
    assertDefaultListenerMethodInvocation();
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) StubTextMessage(org.springframework.jms.StubTextMessage) Session(javax.jms.Session) Test(org.junit.Test)

Example 18 with MessagingMessageListenerAdapter

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

the class MethodJmsListenerEndpointTests method resolveJmsMessageHeaderAccessor.

@Test
public void resolveJmsMessageHeaderAccessor() throws JMSException {
    MessagingMessageListenerAdapter listener = createDefaultInstance(JmsMessageHeaderAccessor.class);
    Session session = mock(Session.class);
    StubTextMessage message = createSimpleJmsTextMessage("my payload");
    message.setBooleanProperty("customBoolean", true);
    message.setJMSPriority(9);
    listener.onMessage(message, session);
    assertDefaultListenerMethodInvocation();
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) StubTextMessage(org.springframework.jms.StubTextMessage) Session(javax.jms.Session) Test(org.junit.Test)

Example 19 with MessagingMessageListenerAdapter

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

the class MethodJmsListenerEndpointTests method processAndReplyWithSendToQueue.

@Test
public void processAndReplyWithSendToQueue() throws JMSException {
    String methodName = "processAndReplyWithSendTo";
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod(methodName, String.class), container);
    processAndReplyWithSendTo(listener, "replyDestination", false);
    assertListenerMethodInvocation(sample, methodName);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.Test)

Example 20 with MessagingMessageListenerAdapter

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

the class MethodJmsListenerEndpointTests method resolveCustomHeaderNameAndPayloadWithHeaderNameSet.

@Test
public void resolveCustomHeaderNameAndPayloadWithHeaderNameSet() throws JMSException {
    MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, int.class);
    Session session = mock(Session.class);
    StubTextMessage message = createSimpleJmsTextMessage("my payload");
    message.setIntProperty("myCounter", 24);
    listener.onMessage(message, session);
    assertDefaultListenerMethodInvocation();
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) StubTextMessage(org.springframework.jms.StubTextMessage) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

MessagingMessageListenerAdapter (org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter)24 Test (org.junit.Test)22 Session (javax.jms.Session)17 StubTextMessage (org.springframework.jms.StubTextMessage)9 SimpleMessageListenerContainer (org.springframework.jms.listener.SimpleMessageListenerContainer)5 Method (java.lang.reflect.Method)2 TextMessage (javax.jms.TextMessage)2 MessageConverter (org.springframework.jms.support.converter.MessageConverter)2 DestinationResolver (org.springframework.jms.support.destination.DestinationResolver)2 MessageConversionException (org.springframework.messaging.converter.MessageConversionException)2 DefaultMessageHandlerMethodFactory (org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory)2 Destination (javax.jms.Destination)1 InvalidDestinationException (javax.jms.InvalidDestinationException)1 ObjectMessage (javax.jms.ObjectMessage)1 QueueSender (javax.jms.QueueSender)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 JmsListenerContainerTestFactory (org.springframework.jms.config.JmsListenerContainerTestFactory)1 MethodJmsListenerEndpoint (org.springframework.jms.config.MethodJmsListenerEndpoint)1 InvocableHandlerMethod (org.springframework.messaging.handler.invocation.InvocableHandlerMethod)1