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
FieldsFields 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
ConstructorsConstructorDescriptionDisruptorEndpoint(String endpointUri, org.apache.camel.Component component, DisruptorReference disruptorReference) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.camel.ConsumercreateConsumer(org.apache.camel.Processor processor) org.apache.camel.Producerprotected voiddoInit()protected voidprotected voiddoStop()booleanintintReturns the current active consumers on this endpointgetName()longReturns the current active producers on this endpointlongintgetSize()longorg.apache.camel.WaitForTaskToCompleteinthashCode()booleanbooleanbooleanvoidsetBlockWhenFull(boolean blockWhenFull) Whether a thread that sends messages to a full Disruptor will block until the ringbuffer's capacity is no longer exhausted.voidsetConcurrentConsumers(int concurrentConsumers) Number of concurrent threads processing exchanges.voidsetMultipleConsumers(boolean multipleConsumers) Specifies whether multiple consumers are allowed.voidsetProducerType(DisruptorProducerType producerType) Defines the producers allowed on the Disruptor.voidsetSize(int size) The maximum capacity of the Disruptors ringbuffer Will be effectively increased to the nearest power of two.voidsetTimeout(long timeout) Timeout (in milliseconds) before a producer will stop waiting for an asynchronous task to complete.voidsetWaitForTaskToComplete(org.apache.camel.WaitForTaskToComplete waitForTaskToComplete) Option to specify whether the caller should wait for the async task to complete or not before continuing.voidsetWaitStrategy(DisruptorWaitStrategy waitStrategy) 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, toStringMethods 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, suspendMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.camel.ComponentAware
getComponent, setComponentMethods inherited from interface org.apache.camel.Endpoint
configureExchange, configureProperties, createAsyncProducer, createExchange, createExchange, createPollingConsumer, getCamelContext, getEndpointBaseUri, getEndpointKey, getEndpointUri, getExchangePattern, isLenientProperties, isSingletonProducer, setCamelContextMethods inherited from interface org.apache.camel.IsSingleton
isSingletonMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
DISRUPTOR_IGNORE_EXCHANGE
- See Also:
-
-
Constructor Details
-
DisruptorEndpoint
public DisruptorEndpoint(String endpointUri, org.apache.camel.Component component, DisruptorReference disruptorReference)
-
-
Method Details
-
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:
isMultipleConsumersSupportedin interfaceorg.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
Returns the current active consumers on this endpoint -
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
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
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
- Specified by:
createProducerin interfaceorg.apache.camel.Endpoint- Throws:
Exception
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception - Specified by:
createConsumerin interfaceorg.apache.camel.Endpoint- Throws:
Exception
-
doInit
- Overrides:
doInitin classorg.apache.camel.support.DefaultEndpoint- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doShutdown
- Overrides:
doShutdownin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
getComponent
- Specified by:
getComponentin interfaceorg.apache.camel.ComponentAware- Overrides:
getComponentin classorg.apache.camel.support.DefaultEndpoint
-
equals
- Overrides:
equalsin classorg.apache.camel.support.DefaultEndpoint
-
hashCode
public int hashCode()- Overrides:
hashCodein classorg.apache.camel.support.DefaultEndpoint
-