Package com.yahoo.feedapi
Class SharedSender
- java.lang.Object
-
- com.yahoo.feedapi.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SharedSender.Pending
static interface
SharedSender.ResultCallback
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RouteMetricSet
getMetrics()
void
handleReply(com.yahoo.messagebus.Reply r)
Implement replyHandler from messagebus.void
send(com.yahoo.messagebus.Message msg, SharedSender.ResultCallback owner)
Sends a messagevoid
send(com.yahoo.messagebus.Message msg, SharedSender.ResultCallback owner, boolean blockingQueue)
Sends a message.void
shutdown()
-
-
-
Field Detail
-
log
public static final Logger log
-
-
Method Detail
-
getMetrics
public RouteMetricSet getMetrics()
-
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 sendowner
- The callback to send replies to when received from messagebusblockingQueue
- 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 interfacecom.yahoo.messagebus.ReplyHandler
- Parameters:
r
- the reply to process.
-
-