Class VisitorDataQueue


  • public class VisitorDataQueue
    extends VisitorDataHandler
    A visitor data handler that queues up documents in visitor responses and implements the getNext methods, thus implementing the polling API defined in VisitorDataHandler.

    Visitor responses should be polled for with the getNext methods and need to be acked when processed for visiting not to halt. The class is thread safe.

    Author:
    HÃ¥kon Humberset, vekterli
    • Constructor Detail

      • VisitorDataQueue

        public VisitorDataQueue()
        Creates a new visitor data queue.
    • Method Detail

      • reset

        public void reset()
        Description copied from class: VisitorDataHandler
        Called before the visitor starts. Override this method if you need to reset local data. Remember to call the superclass' method as well.
        Overrides:
        reset in class VisitorDataHandler
      • onMessage

        public void onMessage​(com.yahoo.messagebus.Message m,
                              AckToken token)
        Description copied from class: VisitorDataHandler
        Called when a data message is received. IMPORTANT: May be called concurrently from multiple threads. Any internal state mutations MUST be done in a thread-safe manner.
        Specified by:
        onMessage in class VisitorDataHandler
        Parameters:
        m - The message received
        token - A token to reply with when finished processing the message.
      • getNext

        public VisitorResponse getNext()
        Description copied from class: VisitorDataHandler
        Returns the next response of this session. This method returns immediately.
        Overrides:
        getNext in class VisitorDataHandler
        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 class: VisitorDataHandler
        Returns the next response of this session. This will block until a response is ready or the given timeout is reached.
        Overrides:
        getNext in class VisitorDataHandler
        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