Package com.yahoo.documentapi.messagebus
Class MessageBusVisitorDestinationSession
- java.lang.Object
-
- com.yahoo.documentapi.messagebus.MessageBusVisitorDestinationSession
-
- All Implemented Interfaces:
VisitorControlSession
,VisitorDestinationSession
,com.yahoo.messagebus.MessageHandler
public class MessageBusVisitorDestinationSession extends java.lang.Object implements VisitorDestinationSession, com.yahoo.messagebus.MessageHandler
A visitor destination session for receiving data from a visitor using a messagebus destination session. The default behaviour of the visitor session is to control visiting and receive the data. As an alternative, you may set up one or more visitor destination sessions and tell the visitor to send data to the remote destination(s). This is convenient if you want to receive data decoupled from controlling the visitor, but also to avoid a single data destination becoming a bottleneck.Create the visitor destination session by calling the
MessageBusDocumentAccess.createVisitorDestinationSession
method. The visitor must be started by calling theMessageBusDocumentAccess.createVisitorSession
method and progress tracked through the resulting visitor session.- Author:
- Thomas Gundersen
-
-
Constructor Summary
Constructors Constructor Description MessageBusVisitorDestinationSession(VisitorDestinationParameters params, com.yahoo.messagebus.MessageBus bus)
Creates a message bus visitor destination session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Aborts the session.void
ack(AckToken token)
Acknowledges a response previously retrieved by thegetNext
method.void
destroy()
Destroys this session and frees up any resources it has held.VisitorResponse
getNext()
Returns the next response of this session.VisitorResponse
getNext(int timeoutMilliseconds)
Returns the next response of this session.void
handleMessage(com.yahoo.messagebus.Message message)
-
-
-
Constructor Detail
-
MessageBusVisitorDestinationSession
public MessageBusVisitorDestinationSession(VisitorDestinationParameters params, com.yahoo.messagebus.MessageBus bus)
Creates a message bus visitor destination session.- Parameters:
params
- the parameters for the visitor destination sessionbus
- the message bus to use
-
-
Method Detail
-
handleMessage
public void handleMessage(com.yahoo.messagebus.Message message)
- Specified by:
handleMessage
in interfacecom.yahoo.messagebus.MessageHandler
-
ack
public void ack(AckToken token)
Description copied from interface:VisitorControlSession
Acknowledges a response previously retrieved by thegetNext
method.- Specified by:
ack
in interfaceVisitorControlSession
- Parameters:
token
- The ack token. You must get this from the visitor response returned by thegetNext
method.
-
destroy
public void destroy()
Description copied from interface:VisitorControlSession
Destroys this session and frees up any resources it has held.- Specified by:
destroy
in interfaceVisitorControlSession
-
abort
public void abort()
Description copied from interface:VisitorControlSession
Aborts the session.- Specified by:
abort
in interfaceVisitorControlSession
-
getNext
public VisitorResponse getNext()
Description copied from interface:VisitorControlSession
Returns the next response of this session. This method returns immediately.- Specified by:
getNext
in interfaceVisitorControlSession
- Returns:
- the next response, or null if no response is ready at this time
-
getNext
public VisitorResponse getNext(int timeoutMilliseconds) throws java.lang.InterruptedException
Description copied from interface:VisitorControlSession
Returns the next response of this session. This will block until a response is ready or until the given timeout is reached- Specified by:
getNext
in interfaceVisitorControlSession
- Parameters:
timeoutMilliseconds
- the max time to wait for a response. If the number is 0, this will block without any timeout limit- Returns:
- the next response, or null if no response becomes ready before the timeout expires
- Throws:
java.lang.InterruptedException
- if this thread is interrupted while waiting
-
-