Skip to content

Consider a ReplyHandler strategy and direct connections between MessageHandlers in a chain [INT-919] #4926

Closed

Description

@spring-operator

Mark Fisher opened INT-919 and commented

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.


Affects: 2.0 M1

Issue Links:

Activity

  1. spring-operator commented on Mar 9, 2010

    @spring-operator
    ContributorAuthor

    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.

  2. spring-operator commented on Mar 9, 2010

    @spring-operator
    ContributorAuthor

    Mark Fisher commented

    The handlers in the chain are now connected through the simplest possible, anonymous implementation of MessageChannel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions