Class EventDispatcher

java.lang.Object
com.bloomberglp.blpapi.EventDispatcher

public final class EventDispatcher extends Object
Dispatches events from one or more sessions through callbacks.

EventDispatcher objects are optionally specified when Session objects are constructed. A single EventDispatcher can be shared by multiple Session objects. The EventDispatcher provides an event-driven interface, generating callbacks from one or more internal threads for one or more sessions.

  • Constructor Details

    • EventDispatcher

      public EventDispatcher() throws IOException
      Same as calling EventDispatcher(1)
      Throws:
      IOException
    • EventDispatcher

      public EventDispatcher(int numThreads) throws IOException
      Create an EventDispatcher with the specified number of dispatcher threads

      If numThreads >= 1, then a pool of numThreads threads is created to dispatch events. The behavior is undefined if numThreads <= 0.

      Parameters:
      numThreads - the number of dispatcher threads to create
      Throws:
      IOException
    • EventDispatcher

      @Deprecated public EventDispatcher(int numThreads, int maxPendingEvents) throws IOException
      Deprecated.
      As of release 3.1.0.0 use SessionOptions.setMaxEventQueueSize(int) for setting the event queue size per session
      Parameters:
      numThreads -
      maxPendingEvents -
      Throws:
      IOException
  • Method Details

    • start

      public boolean start()
      Start generating callbacks for events from Sessions associated with this EventDispatcher
      Returns:
      true on success
    • stop

      public void stop() throws InterruptedException
      Throws:
      InterruptedException
    • stop

      public void stop(EventDispatcher.StopOption stopOption) throws InterruptedException
      Stop generating callbacks for events from sessions

      Stop generating callbacks for events from sessions associated with this EventDispatcher. If the specified stopOption is EventDispatcher.StopOption.SYNC then this method blocks until all current callbacks which were dispatched through this EventDispatcher have completed. If the stopOption is EventDispatcher.StopOption.ASYNC then this method returns immediately and no further callbacks will be dispatched.

      Parameters:
      stopOption -
      Throws:
      InterruptedException
    • dispatcherThread

      public void dispatcherThread()
      Add a event dispatcher thread to this EventDispatcher

      By calling this method applications provide a thread to the EventDispatcher for it to use to dispatch events. This call will not return until the EventDispatcher stops dispatching events. The application can call this method multiple times for the same instance of an EventDispatcher to provide a pool of threads.

      This method will return immediately if this EventDispatcher has not been started.

    • numActiveThreads

      public int numActiveThreads()
      Return the number of active threads dispatching events in this EventDispatcher