public MessageBuilderSupport<T> setReplyToAddress(Address replyTo) { this.properties.setReplyToAddress(replyTo); return this; }
public MessageBuilderSupport<T> setReplyToAddressIfAbsent(Address replyTo) { if (this.properties.getReplyToAddress() == null) { this.properties.setReplyToAddress(replyTo); } return this; }
@Override public Object convertSendAndReceive(Object payload) throws AmqpException { Object[] arguments = ((RemoteInvocation) payload).getArguments(); if (arguments.length == 1 && arguments[0].equals("timeout")) { return null; } MessageConverter messageConverter = serviceExporter.getMessageConverter(); Address replyTo = new Address("fakeExchangeName", "fakeRoutingKey"); MessageProperties messageProperties = new MessageProperties(); messageProperties.setReplyToAddress(replyTo); Message message = messageConverter.toMessage(payload, messageProperties); serviceExporter.onMessage(message); Message resultMessage = sentSavingTemplate.getLastMessage(); return messageConverter.fromMessage(resultMessage); } };
@Test public void processAndReplyUsingReplyTo() throws Exception { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class); listener.setMandatoryPublish(true); String body = "echo text"; Address replyTo = new Address("replyToQueue", "myRouting"); MessageProperties properties = new MessageProperties(); properties.setReplyToAddress(replyTo); org.springframework.amqp.core.Message message = MessageTestUtils.createTextMessage(body, properties); processAndReply(listener, message, "replyToQueue", "myRouting", true, null); assertDefaultListenerMethodInvocation(); }