@FunctionalInterface
public interface MessageHandler
MessageHandler handles a Message sent to a MessageChannel instance.
It uses a variant of the Chain of Responsibility (CoR) design pattern.
To use this interface, consider the following example.
MessageChannel messageChannel = new MessageChannel();
messageChannel.addMessageHandler(new MyMessageHandler());
| Modifier and Type | Method and Description |
|---|---|
boolean |
handle(Message message)
Called when a
MessageChannels sendMessage(Message) method is called. |
boolean handle(Message message)
MessageChannels sendMessage(Message) method is called.
If true is returned, the chain will be broken and the Message will be considered successfully handled.
Breaking the chain technically means that no successive MessageHandler will be able to handle the given Message.
message - the Message to handletrue if, and only if, the Message should be considered successfully handled, false otherwise