Package com.yahoo.messagebus
Class IntermediateSession
- java.lang.Object
-
- com.yahoo.messagebus.IntermediateSession
-
- All Implemented Interfaces:
MessageHandler
,ReplyHandler
public final class IntermediateSession extends java.lang.Object implements MessageHandler, ReplyHandler
A session which supports receiving, forwarding and acknowledgement of messages. An intermediate session is expacted to either forward or acknowledge every message received.- Author:
- Simon Thoresen Hult
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
This method unregisters this session from message bus, effectively disabling any more messages from being delivered to the message handler.boolean
destroy()
Sets the destroyed flag to true.void
forward(Routable routable)
Forwards a routable to the next hop in its route.java.lang.String
getConnectionSpec()
Returns the connection spec string for this session.MessageHandler
getMessageHandler()
Returns the message handler of this sessionjava.lang.String
getName()
Returns the name of this sessionReplyHandler
getReplyHandler()
Returns 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 Detail
-
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()
as 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
public void forward(Routable routable)
Forwards a routable to the next hop in its route. This method will never block.- Parameters:
routable
- the routable to forward.
-
getMessageHandler
public MessageHandler getMessageHandler()
Returns the message handler of this session
-
getReplyHandler
public ReplyHandler getReplyHandler()
Returns the reply handler of this session.- Returns:
- The reply handler.
-
getConnectionSpec
public java.lang.String 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
public java.lang.String getName()
Returns the name of this session
-
handleMessage
public void handleMessage(Message msg)
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
public void handleReply(Reply reply)
Description copied from interface:ReplyHandler
This function is called when a reply arrives.- Specified by:
handleReply
in interfaceReplyHandler
- Parameters:
reply
- The reply that arrived.
-
-