From 64158f454ebef438e9dfcbd38e2c501991d79aeb Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Thu, 2 Oct 2008 00:42:33 +0000 Subject: [PATCH] ReplyMessageCorrelator simply returns the same Message. The base class already resolves the replyChannel from the 'returnAddress' header value. --- .../gateway/ReplyMessageCorrelator.java | 28 +------------------ .../gateway/ReplyMessageCorrelatorTests.java | 2 +- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/gateway/ReplyMessageCorrelator.java b/org.springframework.integration/src/main/java/org/springframework/integration/gateway/ReplyMessageCorrelator.java index 653b2b3085..cf2992c798 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/gateway/ReplyMessageCorrelator.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/gateway/ReplyMessageCorrelator.java @@ -16,11 +16,8 @@ package org.springframework.integration.gateway; -import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.endpoint.AbstractMessageHandlingEndpoint; import org.springframework.integration.message.Message; -import org.springframework.integration.message.MessageHandlingException; -import org.springframework.integration.message.MessagingException; /** * A handler for receiving messages from a "reply channel". @@ -31,30 +28,7 @@ public class ReplyMessageCorrelator extends AbstractMessageHandlingEndpoint { @Override public Message handle(Message message) { - Object returnAddress = message.getHeaders().getReturnAddress(); - if (returnAddress == null) { - throw new MessageHandlingException(message, - "unable to correlate response, message has no returnAddress"); - } - MessageChannel replyChannel = null; - if (returnAddress instanceof MessageChannel) { - replyChannel = (MessageChannel) returnAddress; - } - else if (returnAddress instanceof String) { - replyChannel = this.getChannelRegistry().lookupChannel((String) returnAddress); - if (replyChannel == null) { - throw new MessagingException(message, - "unable to resolve returnAddress '" + returnAddress + "'"); - } - } - else { - throw new MessagingException(message, - "invalid returnAddress type [" + returnAddress.getClass() + "]"); - } - if (replyChannel != null) { - replyChannel.send(message); - } - return null; + return message; } } diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/gateway/ReplyMessageCorrelatorTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/gateway/ReplyMessageCorrelatorTests.java index 5a623207fb..cc7d349e4d 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/gateway/ReplyMessageCorrelatorTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/gateway/ReplyMessageCorrelatorTests.java @@ -36,7 +36,7 @@ public class ReplyMessageCorrelatorTests { QueueChannel replyChannel = new QueueChannel(); Message message = MessageBuilder.withPayload("test") .setCorrelationId("123").setReturnAddress(replyChannel).build(); - correlator.handle(message); + correlator.onMessage(message); Message reply = replyChannel.receive(0); assertEquals("test", reply.getPayload()); }