Class ApplicationEventHandler

java.lang.Object
org.apache.kafka.clients.consumer.internals.events.ApplicationEventHandler
All Implemented Interfaces:
Closeable, AutoCloseable

public class ApplicationEventHandler extends Object implements Closeable
An event handler that receives application events from the application thread which are then readable from the ApplicationEventProcessor in the network thread.
  • Constructor Details

  • Method Details

    • add

      public void add(ApplicationEvent event)
      Add an ApplicationEvent to the handler and then internally invoke wakeupNetworkThread() to alert the network I/O thread that it has something to process.
      Parameters:
      event - An ApplicationEvent created by the application thread
    • wakeupNetworkThread

      public void wakeupNetworkThread()
      Wakeup the network I/O thread to pull the next event(s) from the queue.
    • maximumTimeToWait

      public long maximumTimeToWait()
      Returns the delay for which the application thread can safely wait before it should be responsive to results from the request managers. For example, the subscription state can change when heartbeats are sent, so blocking for longer than the heartbeat interval might mean the application thread is not responsive to changes.
      Returns:
      The maximum delay in milliseconds
    • addAndGet

      public <T> T addAndGet(CompletableApplicationEvent<T> event, org.apache.kafka.common.utils.Timer timer)
      Add a CompletableApplicationEvent to the handler. The method blocks waiting for the result, and will return the result value upon successful completion; otherwise throws an error.

      See CompletableApplicationEvent.get(Timer) and Future.get(long, TimeUnit) for more details.

      Type Parameters:
      T - Type of return value of the event
      Parameters:
      event - A CompletableApplicationEvent created by the polling thread
      timer - Timer for which to wait for the event to complete
      Returns:
      Value that is the result of the event
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • close

      public void close(Duration timeout)