Class DisruptorEndpoint

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultEndpoint
org.apache.camel.component.disruptor.DisruptorEndpoint
All Implemented Interfaces:
AutoCloseable, org.apache.camel.AsyncEndpoint, org.apache.camel.CamelContextAware, org.apache.camel.ComponentAware, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.MultipleConsumersSupport, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.HasId, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

@ManagedResource(description="Managed Disruptor Endpoint") @UriEndpoint(firstVersion="2.12.0", scheme="disruptor,disruptor-vm", title="Disruptor,Disruptor VM", syntax="disruptor:name", category=MESSAGING) public class DisruptorEndpoint extends org.apache.camel.support.DefaultEndpoint implements org.apache.camel.AsyncEndpoint, org.apache.camel.MultipleConsumersSupport
Provides asynchronous SEDA behavior using LMAX Disruptor. This component works much as the standard SEDA Component, but utilizes a Disruptor instead of a BlockingQueue utilized by the standard SEDA.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
    DisruptorEndpoint(String endpointUri, org.apache.camel.Component component, DisruptorReference disruptorReference)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.camel.Consumer
    createConsumer(org.apache.camel.Processor processor)
     
    org.apache.camel.Producer
     
    protected void
     
    protected void
     
    protected void
     
    boolean
    equals(Object object)
     
    int
     
     
    int
     
    Returns the current active consumers on this endpoint
     
    long
     
    Returns the current active producers on this endpoint
     
    long
     
    int
     
    long
     
    org.apache.camel.WaitForTaskToComplete
     
     
    int
     
    boolean
     
    boolean
     
    boolean
     
    void
    setBlockWhenFull(boolean blockWhenFull)
    Whether a thread that sends messages to a full Disruptor will block until the ringbuffer's capacity is no longer exhausted.
    void
    setConcurrentConsumers(int concurrentConsumers)
    Number of concurrent threads processing exchanges.
    void
    setMultipleConsumers(boolean multipleConsumers)
    Specifies whether multiple consumers are allowed.
    void
    Defines the producers allowed on the Disruptor.
    void
    setSize(int size)
    The maximum capacity of the Disruptors ringbuffer Will be effectively increased to the nearest power of two.
    void
    setTimeout(long timeout)
    Timeout (in milliseconds) before a producer will stop waiting for an asynchronous task to complete.
    void
    setWaitForTaskToComplete(org.apache.camel.WaitForTaskToComplete waitForTaskToComplete)
    Option to specify whether the caller should wait for the async task to complete or not before continuing.
    void
    Defines the strategy used by consumer threads to wait on new exchanges to be published.

    Methods inherited from class org.apache.camel.support.DefaultEndpoint

    configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, getCamelContext, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doBuild, doFail, doLifecycleChange, doResume, doStart, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.camel.ComponentAware

    getComponent, setComponent

    Methods inherited from interface org.apache.camel.Endpoint

    configureExchange, configureProperties, createAsyncProducer, createExchange, createExchange, createPollingConsumer, getCamelContext, getEndpointBaseUri, getEndpointKey, getEndpointUri, getExchangePattern, isLenientProperties, isSingletonProducer, setCamelContext

    Methods inherited from interface org.apache.camel.IsSingleton

    isSingleton

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • Field Details

  • Constructor Details

    • DisruptorEndpoint

      public DisruptorEndpoint(String endpointUri, org.apache.camel.Component component, DisruptorReference disruptorReference)
  • Method Details

    • getName

      @ManagedAttribute(description="Queue name") public String getName()
    • getBufferSize

      @ManagedAttribute(description="Buffer max capacity") public int getBufferSize()
    • getRemainingCapacity

      @ManagedAttribute(description="Remaining capacity in ring buffer") public long getRemainingCapacity() throws DisruptorNotStartedException
      Throws:
      DisruptorNotStartedException
    • getPendingExchangeCount

      @ManagedAttribute(description="Amount of pending exchanges waiting for consumption in ring buffer") public long getPendingExchangeCount()
    • getConcurrentConsumers

      @ManagedAttribute(description="Number of concurrent consumers") public int getConcurrentConsumers()
    • setConcurrentConsumers

      public void setConcurrentConsumers(int concurrentConsumers)
      Number of concurrent threads processing exchanges.
    • getWaitForTaskToComplete

      @ManagedAttribute(description="Option to specify whether the caller should wait for the async task to complete or not before continuing") public org.apache.camel.WaitForTaskToComplete getWaitForTaskToComplete()
    • setWaitForTaskToComplete

      public void setWaitForTaskToComplete(org.apache.camel.WaitForTaskToComplete waitForTaskToComplete)
      Option to specify whether the caller should wait for the async task to complete or not before continuing. The following three options are supported: Always, Never or IfReplyExpected. The first two values are self-explanatory. The last value, IfReplyExpected, will only wait if the message is Request Reply based.
    • getTimeout

      @ManagedAttribute(description="Timeout (in milliseconds) before a producer will stop waiting for an asynchronous task to complete") public long getTimeout()
    • setTimeout

      public void setTimeout(long timeout)
      Timeout (in milliseconds) before a producer will stop waiting for an asynchronous task to complete. You can disable timeout by using 0 or a negative value.
    • getSize

      @ManagedAttribute(description="The maximum capacity of the Disruptors ringbuffer") public int getSize()
    • setSize

      public void setSize(int size)
      The maximum capacity of the Disruptors ringbuffer Will be effectively increased to the nearest power of two. Notice: Mind if you use this option, then its the first endpoint being created with the queue name, that determines the size. To make sure all endpoints use same size, then configure the size option on all of them, or the first endpoint being created.
    • isMultipleConsumersSupported

      @ManagedAttribute(description="Specifies whether multiple consumers are allowed") public boolean isMultipleConsumersSupported()
      Specified by:
      isMultipleConsumersSupported in interface org.apache.camel.MultipleConsumersSupport
    • isMultipleConsumers

      public boolean isMultipleConsumers()
    • setMultipleConsumers

      public void setMultipleConsumers(boolean multipleConsumers)
      Specifies whether multiple consumers are allowed. If enabled, you can use Disruptor for Publish-Subscribe messaging. That is, you can send a message to the queue and have each consumer receive a copy of the message. When enabled, this option should be specified on every consumer endpoint.
    • getConsumers

      public Set<DisruptorConsumer> getConsumers()
      Returns the current active consumers on this endpoint
    • getProducers

      public Set<DisruptorProducer> getProducers()
      Returns the current active producers on this endpoint
    • isBlockWhenFull

      @ManagedAttribute public boolean isBlockWhenFull()
    • setBlockWhenFull

      public void setBlockWhenFull(boolean blockWhenFull)
      Whether a thread that sends messages to a full Disruptor will block until the ringbuffer's capacity is no longer exhausted. By default, the calling thread will block and wait until the message can be accepted. By disabling this option, an exception will be thrown stating that the queue is full.
    • getWaitStrategy

      @ManagedAttribute(description="Defines the strategy used by consumer threads to wait on new exchanges to be published") public DisruptorWaitStrategy getWaitStrategy()
    • setWaitStrategy

      public void setWaitStrategy(DisruptorWaitStrategy waitStrategy)
      Defines the strategy used by consumer threads to wait on new exchanges to be published. The options allowed are:Blocking, Sleeping, BusySpin and Yielding.
    • getProducerType

      @ManagedAttribute(description=" Defines the producers allowed on the Disruptor") public DisruptorProducerType getProducerType()
    • setProducerType

      public void setProducerType(DisruptorProducerType producerType)
      Defines the producers allowed on the Disruptor. The options allowed are: Multi to allow multiple producers and Single to enable certain optimizations only allowed when one concurrent producer (on one thread or otherwise synchronized) is active.
    • createProducer

      public org.apache.camel.Producer createProducer() throws Exception
      Specified by:
      createProducer in interface org.apache.camel.Endpoint
      Throws:
      Exception
    • createConsumer

      public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
      Specified by:
      createConsumer in interface org.apache.camel.Endpoint
      Throws:
      Exception
    • doInit

      protected void doInit() throws Exception
      Overrides:
      doInit in class org.apache.camel.support.DefaultEndpoint
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doShutdown

      protected void doShutdown() throws Exception
      Overrides:
      doShutdown in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • getComponent

      public DisruptorComponent getComponent()
      Specified by:
      getComponent in interface org.apache.camel.ComponentAware
      Overrides:
      getComponent in class org.apache.camel.support.DefaultEndpoint
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class org.apache.camel.support.DefaultEndpoint
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class org.apache.camel.support.DefaultEndpoint