INT-1180 Added a 'requiresReply' header. The default value is FALSE, but Gateway request Messages now have this value set to true whenever the invoked method has a non-void return. This will trigger a MessageHandlingException instead of a timeout downstream if no reply is produced by an instance of AbstractReplyProducingMessageHandler.
This commit is contained in:
@@ -58,6 +58,8 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
|
||||
|
||||
public static final String CORRELATION_ID = PREFIX + "correlationId";
|
||||
|
||||
public static final String REQUIRES_REPLY = PREFIX + "requiresReply";
|
||||
|
||||
public static final String REPLY_CHANNEL = PREFIX + "replyChannel";
|
||||
|
||||
public static final String ERROR_CHANNEL = PREFIX + "errorChannel";
|
||||
@@ -98,6 +100,11 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
|
||||
return this.get(REPLY_CHANNEL);
|
||||
}
|
||||
|
||||
public boolean getRequiresReply() {
|
||||
Boolean headerValue = this.get(REQUIRES_REPLY, Boolean.class);
|
||||
return (headerValue != null && headerValue);
|
||||
}
|
||||
|
||||
public Object getErrorChannel() {
|
||||
return this.get(ERROR_CHANNEL);
|
||||
}
|
||||
|
||||
@@ -167,6 +167,10 @@ public final class MessageBuilder<T> {
|
||||
return this.setHeader(MessageHeaders.CORRELATION_ID, correlationId);
|
||||
}
|
||||
|
||||
public MessageBuilder<T> setRequiresReply(Boolean requiresReply) {
|
||||
return this.setHeader(MessageHeaders.REQUIRES_REPLY, requiresReply);
|
||||
}
|
||||
|
||||
public MessageBuilder<T> setReplyChannel(MessageChannel replyChannel) {
|
||||
return this.setHeader(MessageHeaders.REPLY_CHANNEL, replyChannel);
|
||||
}
|
||||
|
||||
@@ -109,6 +109,10 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
|
||||
throw new MessageHandlingException(message, "handler '" + this
|
||||
+ "' requires a reply, but no reply was received");
|
||||
}
|
||||
if (message != null && message.getHeaders().getRequiresReply()) {
|
||||
throw new MessageHandlingException(message,
|
||||
"A reply Message is required by this request Message, but none was received.");
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("handler '" + this + "' produced no reply for request Message: " + message);
|
||||
}
|
||||
|
||||
@@ -236,6 +236,9 @@ public class ArgumentArrayMessageMapper implements InboundMessageMapper<Object[]
|
||||
}
|
||||
builder.copyHeaders(evaluatedHeaders);
|
||||
}
|
||||
if (!void.class.equals(this.method.getReturnType())) {
|
||||
builder.setRequiresReply(true);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user