Search in sources :

Example 6 with MessagingMessageListenerAdapter

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

the class MethodJmsListenerEndpointTests method resolveCustomHeaderNameAndPayload.

@Test
public void resolveCustomHeaderNameAndPayload() 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)

Example 7 with MessagingMessageListenerAdapter

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

the class MethodJmsListenerEndpointTests method resolveMessageHeaders.

@Test
public void resolveMessageHeaders() throws JMSException {
    MessagingMessageListenerAdapter listener = createDefaultInstance(MessageHeaders.class);
    Session session = mock(Session.class);
    StubTextMessage message = createSimpleJmsTextMessage("my payload");
    message.setLongProperty("customLong", 4567L);
    message.setJMSType("myMessageType");
    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 8 with MessagingMessageListenerAdapter

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

the class MethodJmsListenerEndpointTests method processFromTopicAndReplyWithSendToQueue.

@Test
public void processFromTopicAndReplyWithSendToQueue() throws JMSException {
    String methodName = "processAndReplyWithSendTo";
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setPubSubDomain(true);
    container.setReplyPubSubDomain(false);
    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 9 with MessagingMessageListenerAdapter

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

the class MethodJmsListenerEndpointTests method invalidMessagePayloadType.

@Test
public void invalidMessagePayloadType() throws JMSException {
    MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class);
    Session session = mock(Session.class);
    thrown.expect(ListenerExecutionFailedException.class);
    thrown.expectCause(Matchers.isA(MessageConversionException.class));
    // Message<String> as Message<Integer>
    listener.onMessage(createSimpleJmsTextMessage("test"), session);
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) MessageConversionException(org.springframework.messaging.converter.MessageConversionException) Session(javax.jms.Session) Test(org.junit.Test)

Example 10 with MessagingMessageListenerAdapter

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

the class MethodJmsListenerEndpointTests method resolveConvertedPayload.

@Test
public void resolveConvertedPayload() throws JMSException {
    MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class);
    Session session = mock(Session.class);
    listener.onMessage(createSimpleJmsTextMessage("33"), session);
    assertDefaultListenerMethodInvocation();
}
Also used : MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) 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