public class DisruptorConfiguration extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE
The default size of the buffer in this configuration
|
Constructor and Description |
---|
DisruptorConfiguration()
Initializes a configuration instance with default settings: ring-buffer size: 4096, blocking wait strategy and
multi-threaded producer type.
|
Modifier and Type | Method and Description |
---|---|
int |
getBufferSize()
Returns the buffer size to use.
|
Cache |
getCache()
Returns the cache used to store Aggregates loaded by the DisruptorCommandBus.
|
CommandTargetResolver |
getCommandTargetResolver()
Returns the CommandTargetResolver that is used to find out which Aggregate is to be invoked for a given Command.
|
long |
getCoolingDownPeriod()
Returns the cooling down period for the shutdown of the DisruptorCommandBus, in milliseconds.
|
List<MessageDispatchInterceptor<? super CommandMessage<?>>> |
getDispatchInterceptors()
Returns the dispatch interceptors for the DisruptorCommandBus.
|
Executor |
getExecutor()
Returns the Executor providing the processing resources (Threads) for the DisruptorCommandBus.
|
List<MessageHandlerInterceptor<? super CommandMessage<?>>> |
getInvokerInterceptors()
Returns the interceptors for the DisruptorCommandBus.
|
int |
getInvokerThreadCount()
Returns the number of threads to use for Command Handler invocation.
|
MessageMonitor<? super CommandMessage<?>> |
getMessageMonitor()
Returns the message monitor to use.
|
com.lmax.disruptor.dsl.ProducerType |
getProducerType()
Returns the producer type to use.
|
List<MessageHandlerInterceptor<? super CommandMessage<?>>> |
getPublisherInterceptors()
Returns the interceptors for the DisruptorCommandBus.
|
int |
getPublisherThreadCount()
Returns the number of threads to use for storing and publication of generated Events.
|
boolean |
getRescheduleCommandsOnCorruptState()
Indicates whether commands that failed due to potentially corrupt Aggregate state should be automatically
rescheduled for processing.
|
RollbackConfiguration |
getRollbackConfiguration()
Returns the RollbackConfiguration indicating for which Exceptions the DisruptorCommandBus should perform a
rollback, and which exceptions should result in a Commit.
|
Serializer |
getSerializer()
Returns the serializer to perform pre-serialization with, or
null if no pre-serialization should be
done. |
TransactionManager |
getTransactionManager()
Returns the transaction manager to use to manage a transaction around the storage and publication of events.
|
com.lmax.disruptor.WaitStrategy |
getWaitStrategy()
Returns the WaitStrategy currently configured.
|
DisruptorConfiguration |
setBufferSize(int newBufferSize)
Sets the buffer size to use.
|
DisruptorConfiguration |
setCache(Cache cache)
Sets the cache in which loaded aggregates will be stored.
|
DisruptorConfiguration |
setCommandTargetResolver(CommandTargetResolver newCommandTargetResolver)
Sets the CommandTargetResolver that must be used to indicate which Aggregate instance will be invoked by an
incoming command.
|
DisruptorConfiguration |
setCoolingDownPeriod(long coolingDownPeriod)
Sets the cooling down period in milliseconds.
|
DisruptorConfiguration |
setDispatchInterceptors(List<MessageDispatchInterceptor<CommandMessage<?>>> dispatchInterceptors)
Configures the CommandDispatchInterceptor to use with the DisruptorCommandBus when commands are dispatched.
|
DisruptorConfiguration |
setExecutor(Executor executor)
Sets the Executor that provides the processing resources (Threads) for the components of the DisruptorCommandBus.
|
DisruptorConfiguration |
setInvokerInterceptors(List<MessageHandlerInterceptor<? super CommandMessage<?>>> invokerInterceptors)
Configures the CommandHandlerInterceptors to use with the DisruptorCommandBus during in the invocation thread.
|
DisruptorConfiguration |
setInvokerThreadCount(int count)
Sets the number of Threads that should be used to invoke the Command Handlers.
|
DisruptorConfiguration |
setMessageMonitor(MessageMonitor<? super CommandMessage<?>> messageMonitor)
Sets the message monitor to use.
|
DisruptorConfiguration |
setProducerType(com.lmax.disruptor.dsl.ProducerType producerType)
Sets the producer type to use.
|
DisruptorConfiguration |
setPublisherInterceptors(List<MessageHandlerInterceptor<CommandMessage<?>>> publisherInterceptors)
Configures the CommandHandlerInterceptors to use with the DisruptorCommandBus during the publication of changes.
|
DisruptorConfiguration |
setPublisherThreadCount(int count)
Sets the number of Threads that should be used to store and publish the generated Events.
|
DisruptorConfiguration |
setRescheduleCommandsOnCorruptState(boolean rescheduleCommandsOnCorruptState)
Indicates whether commands that failed because they were executed against potentially corrupted aggregate state
should be automatically rescheduled.
|
DisruptorConfiguration |
setRollbackConfiguration(RollbackConfiguration rollbackConfiguration)
Sets the rollback configuration for the DisruptorCommandBus to use.
|
DisruptorConfiguration |
setSerializer(Serializer newSerializer)
Returns the serializer to perform pre-serialization with, or
null if no pre-serialization should be
done. |
DisruptorConfiguration |
setTransactionManager(TransactionManager newTransactionManager)
Sets the transaction manager to use to manage a transaction around the storage and publication of events.
|
DisruptorConfiguration |
setWaitStrategy(com.lmax.disruptor.WaitStrategy waitStrategy)
Sets the
WaitStrategy , which used to make dependent threads wait for tasks to be completed. |
public static final int DEFAULT_BUFFER_SIZE
public DisruptorConfiguration()
public com.lmax.disruptor.WaitStrategy getWaitStrategy()
public DisruptorConfiguration setWaitStrategy(com.lmax.disruptor.WaitStrategy waitStrategy)
WaitStrategy
, which used to make dependent threads wait for tasks to be completed. The
choice of strategy mainly depends on the number of processors available and the number of tasks other than the
DisruptorCommandBus
being processed.
The BusySpinWaitStrategy
provides the best throughput at the lowest latency, but also put a big
claim on available CPU resources. The SleepingWaitStrategy
yields lower performance, but leaves
resources available for other processes to use.
Defaults to the BlockingWaitStrategy
.waitStrategy
- The WaitStrategy to usethis
for method chainingSleepingWaitStrategy
,
BlockingWaitStrategy
,
BusySpinWaitStrategy
,
YieldingWaitStrategy
public Executor getExecutor()
public DisruptorConfiguration setExecutor(Executor executor)
null
, causing the DisruptorCommandBus to create the necessary threads itself. In that
case, threads are created in the DisruptorCommandBus
ThreadGroup.executor
- the Executor that provides the processing resourcesthis
for method chainingpublic List<MessageHandlerInterceptor<? super CommandMessage<?>>> getInvokerInterceptors()
public DisruptorConfiguration setInvokerInterceptors(List<MessageHandlerInterceptor<? super CommandMessage<?>>> invokerInterceptors)
setPublisherInterceptors(java.util.List)
.invokerInterceptors
- The interceptors to invoke when handling an incoming commandthis
for method chainingpublic List<MessageHandlerInterceptor<? super CommandMessage<?>>> getPublisherInterceptors()
public DisruptorConfiguration setPublisherInterceptors(List<MessageHandlerInterceptor<CommandMessage<?>>> publisherInterceptors)
publisherInterceptors
- The interceptors to invoke when handling an incoming commandthis
for method chainingpublic List<MessageDispatchInterceptor<? super CommandMessage<?>>> getDispatchInterceptors()
public DisruptorConfiguration setDispatchInterceptors(List<MessageDispatchInterceptor<CommandMessage<?>>> dispatchInterceptors)
dispatchInterceptors
- The dispatch interceptors to invoke when dispatching a commandthis
for method chainingpublic RollbackConfiguration getRollbackConfiguration()
public DisruptorConfiguration setRollbackConfiguration(RollbackConfiguration rollbackConfiguration)
RollbackConfigurationType.UNCHECKED_EXCEPTIONS
, a configuration that commits on checked exceptions, and performs
a rollback on runtime exceptions.rollbackConfiguration
- the RollbackConfiguration indicating for the DisruptorCommandBusthis
for method chainingpublic boolean getRescheduleCommandsOnCorruptState()
true
if commands are automatically rescheduled, otherwise false
public DisruptorConfiguration setRescheduleCommandsOnCorruptState(boolean rescheduleCommandsOnCorruptState)
true
.rescheduleCommandsOnCorruptState
- whether or not to automatically reschedule commands that failed due to
potentially corrupted aggregate state.this
for method chainingpublic long getCoolingDownPeriod()
public DisruptorConfiguration setCoolingDownPeriod(long coolingDownPeriod)
coolingDownPeriod
- the cooling down period for the shutdown of the DisruptorCommandBus, in milliseconds.this
for method chainingpublic Cache getCache()
public DisruptorConfiguration setCache(Cache cache)
cache
- The cache to store loaded aggregates in.this
for method chainingpublic CommandTargetResolver getCommandTargetResolver()
public DisruptorConfiguration setCommandTargetResolver(CommandTargetResolver newCommandTargetResolver)
invokerThreadCount
, or publisherThreadCount
is greater than 1.
Defaults to an AnnotationCommandTargetResolver
instance.newCommandTargetResolver
- The CommandTargetResolver to use to indicate which Aggregate instance is target
of an incoming Commandthis
for method chainingpublic int getInvokerThreadCount()
public DisruptorConfiguration setInvokerThreadCount(int count)
1 .. ([processor count] / 2)
.count
- The number of Threads to use for Command Handler invocationthis
for method chainingpublic int getPublisherThreadCount()
public DisruptorConfiguration setPublisherThreadCount(int count)
[processors / 2]
.count
- The number of Threads to use for publishingthis
for method chainingpublic Serializer getSerializer()
null
if no pre-serialization should be
done.null
if no pre-serialization should be
donepublic DisruptorConfiguration setSerializer(Serializer newSerializer)
null
if no pre-serialization should be
done. Defaults to null
.newSerializer
- the serializer to perform pre-serialization with, or null
if no
pre-serialization should be donethis
for method chainingpublic TransactionManager getTransactionManager()
null
if none is configured.public DisruptorConfiguration setTransactionManager(TransactionManager newTransactionManager)
null
) is to not have publication and storage of events wrapped in a transaction.newTransactionManager
- the transaction manager to use to manage a transaction around the storage and
publication of eventsthis
for method chainingpublic int getBufferSize()
public DisruptorConfiguration setBufferSize(int newBufferSize)
newBufferSize
- the buffer size to usethis
for method chainingpublic com.lmax.disruptor.dsl.ProducerType getProducerType()
public DisruptorConfiguration setProducerType(com.lmax.disruptor.dsl.ProducerType producerType)
producerType
- the producer type to usethis
for method chainingpublic MessageMonitor<? super CommandMessage<?>> getMessageMonitor()
public DisruptorConfiguration setMessageMonitor(MessageMonitor<? super CommandMessage<?>> messageMonitor)
messageMonitor
- the message monitor to use.this
for method chainingCopyright © 2010–2018. All rights reserved.