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 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 calls MessageBus.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

      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 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 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 interface MessageHandler
      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 interface ReplyHandler
      Parameters:
      reply - The reply that arrived.
    • connect

      public void connect()
      Specified by:
      connect in interface Connectable
    • disconnect

      public void disconnect()
      Specified by:
      disconnect in interface Connectable