Java Code Examples for org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter#onMessage()
The following examples show how to use
org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter#onMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void processAndReply() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class); String body = "echo text"; String correlationId = "link-1234"; Destination replyDestination = new Destination() {}; TextMessage reply = mock(TextMessage.class); QueueSender queueSender = mock(QueueSender.class); Session session = mock(Session.class); given(session.createTextMessage(body)).willReturn(reply); given(session.createProducer(replyDestination)).willReturn(queueSender); listener.setDefaultResponseDestination(replyDestination); StubTextMessage inputMessage = createSimpleJmsTextMessage(body); inputMessage.setJMSCorrelationID(correlationId); listener.onMessage(inputMessage, session); assertDefaultListenerMethodInvocation(); verify(reply).setJMSCorrelationID(correlationId); verify(queueSender).send(reply); verify(queueSender).close(); }
Example 2
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void processAndReply() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class); String body = "echo text"; String correlationId = "link-1234"; Destination replyDestination = new Destination() {}; TextMessage reply = mock(TextMessage.class); QueueSender queueSender = mock(QueueSender.class); Session session = mock(Session.class); given(session.createTextMessage(body)).willReturn(reply); given(session.createProducer(replyDestination)).willReturn(queueSender); listener.setDefaultResponseDestination(replyDestination); StubTextMessage inputMessage = createSimpleJmsTextMessage(body); inputMessage.setJMSCorrelationID(correlationId); listener.onMessage(inputMessage, session); assertDefaultListenerMethodInvocation(); verify(reply).setJMSCorrelationID(correlationId); verify(queueSender).send(reply); verify(queueSender).close(); }
Example 3
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void resolveConvertedPayload() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class); Session session = mock(Session.class); listener.onMessage(createSimpleJmsTextMessage("33"), session); assertDefaultListenerMethodInvocation(); }
Example 4
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@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(); }
Example 5
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@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(); }
Example 6
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void resolveHeaderAndPayload() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, int.class); Session session = mock(Session.class); StubTextMessage message = createSimpleJmsTextMessage("my payload"); message.setIntProperty("myCounter", 55); listener.onMessage(message, session); assertDefaultListenerMethodInvocation(); }
Example 7
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@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(); }
Example 8
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void resolveConvertedPayload() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class); Session session = mock(Session.class); listener.onMessage(createSimpleJmsTextMessage("33"), session); assertDefaultListenerMethodInvocation(); }
Example 9
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void resolveGenericMessage() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class); Session session = mock(Session.class); listener.onMessage(createSimpleJmsTextMessage("test"), session); assertDefaultListenerMethodInvocation(); }
Example 10
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
private void processAndReplyWithSendTo(MessagingMessageListenerAdapter listener, String replyDestinationName, boolean pubSubDomain, QosSettings replyQosSettings) throws JMSException { String body = "echo text"; String correlationId = "link-1234"; Destination replyDestination = new Destination() {}; DestinationResolver destinationResolver = mock(DestinationResolver.class); TextMessage reply = mock(TextMessage.class); QueueSender queueSender = mock(QueueSender.class); Session session = mock(Session.class); given(destinationResolver.resolveDestinationName(session, replyDestinationName, pubSubDomain)) .willReturn(replyDestination); given(session.createTextMessage(body)).willReturn(reply); given(session.createProducer(replyDestination)).willReturn(queueSender); listener.setDestinationResolver(destinationResolver); StubTextMessage inputMessage = createSimpleJmsTextMessage(body); inputMessage.setJMSCorrelationID(correlationId); listener.onMessage(inputMessage, session); verify(destinationResolver).resolveDestinationName(session, replyDestinationName, pubSubDomain); verify(reply).setJMSCorrelationID(correlationId); if (replyQosSettings != null) { verify(queueSender).send(reply, replyQosSettings.getDeliveryMode(), replyQosSettings.getPriority(), replyQosSettings.getTimeToLive()); } else { verify(queueSender).send(reply); } verify(queueSender).close(); }
Example 11
Source File: AbstractJmsAnnotationDrivenTests.java From spring-analysis-note with MIT License | 5 votes |
/** * Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified * in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}. * * The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException} */ public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException { JmsListenerContainerTestFactory simpleFactory = context.getBean("defaultFactory", JmsListenerContainerTestFactory.class); assertEquals(1, simpleFactory.getListenerContainers().size()); MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint(); SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); endpoint.setupListenerContainer(container); MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener(); listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class)); }
Example 12
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@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(); }
Example 13
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void resolveConvertedPayload() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class); Session session = mock(Session.class); listener.onMessage(createSimpleJmsTextMessage("33"), session); assertDefaultListenerMethodInvocation(); }
Example 14
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void resolveObjectPayload() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(MyBean.class); MyBean myBean = new MyBean(); myBean.name = "myBean name"; Session session = mock(Session.class); ObjectMessage message = mock(ObjectMessage.class); given(message.getObject()).willReturn(myBean); listener.onMessage(message, session); assertDefaultListenerMethodInvocation(); }
Example 15
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@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(); }
Example 16
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void invalidPayloadType() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class); Session session = mock(Session.class); thrown.expect(ListenerExecutionFailedException.class); thrown.expectCause(Matchers.isA(MessageConversionException.class)); thrown.expectMessage(getDefaultListenerMethod(Integer.class).toGenericString()); // ref to method listener.onMessage(createSimpleJmsTextMessage("test"), session); // test is not a valid integer }
Example 17
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@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(); }
Example 18
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void resolveHeaderAndPayload() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, int.class); Session session = mock(Session.class); StubTextMessage message = createSimpleJmsTextMessage("my payload"); message.setIntProperty("myCounter", 55); listener.onMessage(message, session); assertDefaultListenerMethodInvocation(); }
Example 19
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void emptySendTo() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class); TextMessage reply = mock(TextMessage.class); Session session = mock(Session.class); given(session.createTextMessage("content")).willReturn(reply); thrown.expect(ReplyFailureException.class); thrown.expectCause(Matchers.isA(InvalidDestinationException.class)); listener.onMessage(createSimpleJmsTextMessage("content"), session); }
Example 20
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void resolveMessageAndSession() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(javax.jms.Message.class, Session.class); Session session = mock(Session.class); listener.onMessage(createSimpleJmsTextMessage("test"), session); assertDefaultListenerMethodInvocation(); }