Class EventQueue

java.lang.Object
com.bloomberglp.blpapi.EventQueue

public class EventQueue extends Object
The EventQueue class allows an application to block and receive Events for requests in a synchronous manner.

An Request can be associated with an EventQueue by passing a valid instance of the EventQueue class to the sendRequest and sendAuthorizationRequest methods. All responses to the Request are now delivered to this EventQueue allowing the application to block for Responses for the Request. Note that a single EventQueue can be used for receiving Response Events for many requests.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct an empty event queue.
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the next event available for processing on this EventQueue
    nextEvent(long timeoutMillis)
    Retrieves the next event available for processing on this EventQueue
    void
    Purge all events from this Event Queue and cancel all Requests that this Event Queue is associated with
    Tries to retrieve the next event available for processing on this EventQueue

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EventQueue

      public EventQueue()
      Construct an empty event queue.
  • Method Details

    • nextEvent

      public Event nextEvent() throws InterruptedException
      Retrieves the next event available for processing on this EventQueue

      This method is the same as calling nextEvent(0)

      Returns:
      next event available on this session
      Throws:
      InterruptedException - if another thread has interrupted the current thread
    • nextEvent

      public Event nextEvent(long timeoutMillis) throws InterruptedException
      Retrieves the next event available for processing on this EventQueue

      retrieve the next event available for processing on this EventQueue. If no event is available immediately wait for timeoutMillis milliseconds for an event to arrive. If no event is received before the timeout expires return a Event.EventType.TIMEOUT event. If the timeout specified is 0 then wait for an infinite amount of time for an event to be received.

      Parameters:
      timeoutMillis - timeout in milliseconds to wait for an event to be available
      Returns:
      next event available before timeout or Event.EventType.TIMEOUT event if timeout occurs
      Throws:
      InterruptedException - if another thread has interrupted the current thread
    • tryNextEvent

      public Event tryNextEvent()
      Tries to retrieve the next event available for processing on this EventQueue

      This method never blocks.

      Returns:
      next event available on this session if available or null if no event is available immediately
    • purge

      public void purge()
      Purge all events from this Event Queue and cancel all Requests that this Event Queue is associated with

      Purges any Event objects in this EventQueue which have not been processed and cancel any pending requests linked to this EventQueue. The EventQueue can subsequently be re-used for a subsequent request.