Package com.yahoo.messagebus
Class Sequencer
java.lang.Object
com.yahoo.messagebus.Sequencer
- All Implemented Interfaces:
MessageHandler
,ReplyHandler
Sequencing is implemented as a message handler that is configured in a source session in that session's chain of
linked message handlers. Each message that carries a sequencing id is queued in an internal list of messages for that
id, and messages are only sent when they are at the front of their list. When a reply arrives, the current front of
the list is removed and the next message, if any, is sent.
- Author:
- Simon Thoresen Hult
-
Constructor Summary
ConstructorDescriptionSequencer
(MessageHandler sender) Sequencer
(MessageHandler sender, Messenger msn) Constructs a new sequencer on top of the given async sender. -
Method Summary
Modifier and TypeMethodDescriptionboolean
destroy()
Sets the destroyed flag to true.void
handleMessage
(Message msg) All messages pass through this handler when being sent by the owning source session.void
handleReply
(Reply reply) Lookup the sequencing id of an incoming reply to pop the front of the corresponding queue, and then send the next message in line, if any.
-
Constructor Details
-
Sequencer
Constructs a new sequencer on top of the given async sender.- Parameters:
sender
- The underlying sender.
-
Sequencer
-
-
Method Details
-
destroy
public boolean destroy()Sets the destroyed flag to true. The very first time this method is called, it cleans up all its dependencies. Even if you retain a reference to this object, all of its content is allowed to be garbage collected.- Returns:
- True if content existed and was destroyed.
-
handleMessage
All messages pass through this handler when being sent by the owning source session. In case the message has no sequencing-id, it is simply passed through to the next handler in the chain. Sequenced messages are sent only if there is no queue for their id, otherwise they are queued.- Specified by:
handleMessage
in interfaceMessageHandler
- Parameters:
msg
- the message to send.
-
handleReply
Lookup the sequencing id of an incoming reply to pop the front of the corresponding queue, and then send the next message in line, if any.- Specified by:
handleReply
in interfaceReplyHandler
- Parameters:
reply
- The reply received.
-