Package com.yahoo.messagebus
Class IntermediateSession
java.lang.Object
com.yahoo.messagebus.IntermediateSession
- All Implemented Interfaces:
Connectable
,MessageHandler
,ReplyHandler
public final class IntermediateSession
extends Object
implements MessageHandler, ReplyHandler, Connectable
A session which supports receiving, forwarding and acknowledging messages. An intermediate session is expected
to either forward or acknowledge every message received.
- Author:
- Simon Thoresen Hult
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
This method unregisters this session from message bus, effectively disabling any more messages from being delivered to the message handler.void
connect()
boolean
destroy()
Sets the destroyed flag to true.void
void
Forwards a routable to the next hop in its route.Returns the connection spec string for this session.Returns the message handler of this sessiongetName()
Returns the name of this sessionReturns the reply handler of this session.void
handleMessage
(Message msg) This function is called when a message arrives.void
handleReply
(Reply reply) This function is called when a reply arrives.
-
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
-
close
public void close()This method unregisters this session from message bus, effectively disabling any more messages from being delivered to the message handler. After unregistering, this method callsMessageBus.sync()
to ensure that there are no threads currently entangled in the handler. This method will deadlock if you call it from the message or reply handler. -
forward
Forwards a routable to the next hop in its route. This method will never block.- Parameters:
routable
- the routable to forward.
-
getMessageHandler
Returns the message handler of this session -
getReplyHandler
Returns the reply handler of this session.- Returns:
- The reply handler.
-
getConnectionSpec
Returns the connection spec string for this session. This returns a combination of the owning message bus' own spec string and the name of this session. -
getName
Returns the name of this session -
handleMessage
Description copied from interface:MessageHandler
This function is called when a message arrives.- Specified by:
handleMessage
in interfaceMessageHandler
- Parameters:
msg
- The message that arrived.
-
handleReply
Description copied from interface:ReplyHandler
This function is called when a reply arrives.- Specified by:
handleReply
in interfaceReplyHandler
- Parameters:
reply
- The reply that arrived.
-
connect
public void connect()- Specified by:
connect
in interfaceConnectable
-
disconnect
public void disconnect()- Specified by:
disconnect
in interfaceConnectable
-