You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider a ReplyHandler strategy and direct connections between MessageHandlers in a chain [INT-919] #4926
Currently, the AbstractReplyProducingMessageHandler has a lot of responsibilities, one of which is the sending of reply messages to the output channel.
We might want to consider factoring out reply-channel resolution (see #4925) as well as the actual "sending" logic. The latter could be managed by a ReplyHandler strategy. This would provide better symmetry in the current AbstractReplyProducingMessageHandler, resulting in something closer to this:
protected final void handleMessageInternal(Message<?> requestMessage) {
Object result = this.handleRequestMessage(message);
Message<?> reply = this.createReplyMessage(result, requestMessage);
if (reply != null) {
this.replyHandler.handleMessage(reply);
}
}
As shown in the example above, we could even consider having the 'replyHandler' be an instance of MessageHandler itself.
When creating a MessageHandlerChain, the replyHandler set on each non-terminal MessageHandler could have a reference to the next handler in the chain. This way we don't even need to create anonymous channels between the handlers. Instead, the handlers can be invoked directly.
I am now leaning toward the "flip" side of this: outputchannel that simply delegates to a MessageHandler.
The core model depends on the decoupling via channels:
producer -> channel -> consumer
What a chain is actually doing is creating the simplest possible channel that invokes another handler without any extra overhead at all. The power of the chain is that those same channels can always be replaced down the road if some intermediate requirement is necessary (transformation, filtering, routing, etc), and such a change would have no impact on the producer or consumer directly.
Activity
spring-operator commentedon Mar 9, 2010
Mark Fisher commented
I am now leaning toward the "flip" side of this: outputchannel that simply delegates to a MessageHandler.
The core model depends on the decoupling via channels:
producer -> channel -> consumer
What a chain is actually doing is creating the simplest possible channel that invokes another handler without any extra overhead at all. The power of the chain is that those same channels can always be replaced down the road if some intermediate requirement is necessary (transformation, filtering, routing, etc), and such a change would have no impact on the producer or consumer directly.
spring-operator commentedon Mar 9, 2010
Mark Fisher commented
The handlers in the chain are now connected through the simplest possible, anonymous implementation of MessageChannel.