@Test public void processAndReplyWithMessage() throws Exception { MessagingMessageListenerAdapter listener = createDefaultInstance(org.springframework.amqp.core.Message.class); listener.setMessageConverter(null); listener.setResponseExchange("fooQueue"); String body = "echo text"; org.springframework.amqp.core.Message message = MessageTestUtils.createTextMessage(body, new MessageProperties()); processAndReply(listener, message, "fooQueue", "", false, null); assertDefaultListenerMethodInvocation(); }
@Test public void processAndReplyWithMessageAndStringReply() throws Exception { MessagingMessageListenerAdapter listener = createDefaultInstance(org.springframework.amqp.core.Message.class); listener.setMessageConverter(null); listener.setResponseExchange("fooQueue"); String body = "echo text"; org.springframework.amqp.core.Message message = MessageTestUtils.createTextMessage(body, new MessageProperties()); try { processAndReply(listener, message, "fooQueue", "", false, null); fail("Should have fail. Not converter and the reply is not a message"); } catch (ReplyFailureException ex) { Throwable cause = ex.getCause(); assertNotNull(cause); assertEquals(MessageConversionException.class, cause.getClass()); assertTrue(ex.getMessage().contains("foo")); // exception holds the content of the reply } assertDefaultListenerMethodInvocation(); }
@Test public void processAndReply() throws Exception { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class); String body = "echo text"; String correlationId = "link-1234"; String responseExchange = "fooQueue"; String responseRoutingKey = "abc-1234"; listener.setResponseExchange(responseExchange); listener.setResponseRoutingKey(responseRoutingKey); MessageProperties properties = new MessageProperties(); properties.setCorrelationId(correlationId); org.springframework.amqp.core.Message message = MessageTestUtils.createTextMessage(body, properties); processAndReply(listener, message, responseExchange, responseRoutingKey, false, correlationId); assertDefaultListenerMethodInvocation(); }