Class SharedSender

  • All Implemented Interfaces:
    com.yahoo.messagebus.ReplyHandler

    public class SharedSender
    extends Object
    implements com.yahoo.messagebus.ReplyHandler
    This class allows multiple clients to use one shared messagebus session. The user should create a ResultCallback, which acts as a "session" for that client, and send one or more messages using the send() methods. When done sending messages, the client can wait for all messages to be replied to using the waitForPending method.
    • Field Detail

      • log

        public static final Logger log
    • Method Detail

      • shutdown

        public void shutdown()
      • send

        public void send​(com.yahoo.messagebus.Message msg,
                         SharedSender.ResultCallback owner)
        Sends a message
        Parameters:
        msg - The message to send.
        owner - A callback to send replies to when received from messagebus
      • send

        public void send​(com.yahoo.messagebus.Message msg,
                         SharedSender.ResultCallback owner,
                         boolean blockingQueue)
        Sends a message. Waits until the number of pending messages for this owner has become lower than the specified limit if necessary.
        Parameters:
        msg - The message to send
        owner - The callback to send replies to when received from messagebus
        blockingQueue - If true, block until the message bus queue is available.
      • handleReply

        public void handleReply​(com.yahoo.messagebus.Reply r)
        Implement replyHandler from messagebus. Called when a reply is received from messagebus. Tries to find the callback from the reply context and updates the pending state for the callback.
        Specified by:
        handleReply in interface com.yahoo.messagebus.ReplyHandler
        Parameters:
        r - the reply to process.