Added support for the 'expect-reply' attribute in JmsGatewayParser. SimpleMessagingGateway now returns void instead of boolean, but it throws a MessageDeliveryException if the underlying RequestReplyTemplate fails to send the Message to the request channel.

This commit is contained in:
Mark Fisher
2008-05-14 14:38:58 +00:00
parent 2b8b4f5a7e
commit 18d03ae2d7
3 changed files with 10 additions and 5 deletions

View File

@@ -109,7 +109,7 @@ public class JmsGateway extends SimpleMessagingGateway implements Lifecycle, Dis
}
MessageListenerAdapter listener = new MessageListenerAdapter();
listener.setDelegate(this);
listener.setDefaultListenerMethod(this.expectReply ? "request" : "send");
listener.setDefaultListenerMethod(this.expectReply ? "sendAndReceive" : "send");
listener.setMessageConverter(this.messageConverter);
this.container.setMessageListener(listener);
if (!this.container.isActive()) {

View File

@@ -102,6 +102,9 @@ public class JmsGatewayParser extends AbstractSingleBeanDefinitionParser {
if (StringUtils.hasText(replyTimeout)) {
builder.addPropertyValue("replyTimeout", Long.parseLong(replyTimeout));
}
if ("true".equals(element.getAttribute("expect-reply"))) {
builder.addPropertyValue("expectReply", Boolean.TRUE);
}
}
}

View File

@@ -21,6 +21,7 @@ import org.springframework.integration.message.DefaultMessageCreator;
import org.springframework.integration.message.DefaultMessageMapper;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageCreator;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.MessageMapper;
import org.springframework.util.Assert;
@@ -59,13 +60,14 @@ public class SimpleMessagingGateway extends MessagingGatewaySupport {
this.messageMapper = messageMapper;
}
public boolean send(Object object) {
public void send(Object object) {
Message<?> message = (object instanceof Message) ? (Message) object :
this.messageCreator.createMessage(object);
if (message == null) {
return false;
if (message != null) {
if (!this.getRequestReplyTemplate().send(message)) {
throw new MessageDeliveryException(message, "failed to send Message to channel");
}
}
return this.getRequestReplyTemplate().send(message);
}
public Object receive() {