Class DurableLocalCommandBus
- java.lang.Object
-
- dk.cloudcreate.essentials.reactive.command.AbstractCommandBus
-
- dk.cloudcreate.essentials.components.foundation.reactive.command.DurableLocalCommandBus
-
- All Implemented Interfaces:
Lifecycle,CommandBus
public class DurableLocalCommandBus extends AbstractCommandBus implements Lifecycle
Provides a JVM local and durable, in regard tosendAndDontWait(Object)/sendAndDontWait(Object, Duration)), variant of theCommandBusconcept
Durability forsendAndDontWait(Object)/sendAndDontWait(Object, Duration)) is delegated toDurableQueues
WhichQueueNamethat is used will be determined by the specifiedgetCommandQueueName()
TheRedeliveryPolicyis determined by the specifiedgetCommandQueueRedeliveryPolicy()
Note: If theSendAndDontWaitErrorHandlerprovided doesn't rethrow the exception, then the underlyingDurableQueueswill not be able to retry the command.
Due to this theDurableLocalCommandBusdefaults to using theSendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler- See Also:
AnnotatedCommandHandler
-
-
Field Summary
Fields Modifier and Type Field Description static QueueNameDEFAULT_COMMAND_QUEUE_NAMEstatic RedeliveryPolicyDEFAULT_REDELIVERY_POLICY-
Fields inherited from class dk.cloudcreate.essentials.reactive.command.AbstractCommandBus
commandHandlers, commandTypeToCommandHandlerCache, interceptors, sendAndDontWaitErrorHandler
-
-
Constructor Summary
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DurableLocalCommandBusBuilderbuilder()Builder for aDurableLocalCommandBusBuilderQueueNamegetCommandQueueName()RedeliveryPolicygetCommandQueueRedeliveryPolicy()intgetParallelSendAndDontWaitConsumers()booleanisStarted()Returns true if the process is started<C> voidsendAndDontWait(C command)<C> voidsendAndDontWait(C command, Duration delayMessageDelivery)voidstart()Start the processing.voidstop()Stop the processing.-
Methods inherited from class dk.cloudcreate.essentials.reactive.command.AbstractCommandBus
addCommandHandler, addInterceptor, findCommandHandlerCapableOfHandling, getInterceptors, hasCommandHandler, hasInterceptor, removeCommandHandler, removeInterceptor, send, sendAsync, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface dk.cloudcreate.essentials.reactive.command.CommandBus
addInterceptors
-
-
-
-
Field Detail
-
DEFAULT_COMMAND_QUEUE_NAME
public static final QueueName DEFAULT_COMMAND_QUEUE_NAME
-
DEFAULT_REDELIVERY_POLICY
public static final RedeliveryPolicy DEFAULT_REDELIVERY_POLICY
-
-
Constructor Detail
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues)
Create a newDurableLocalCommandBususing defaults:- Parameters:
durableQueues- the underlying Durable Queues provider
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, RedeliveryPolicy commandQueueRedeliveryPolicy)
Create a newDurableLocalCommandBususing defaults:- Parameters:
durableQueues- the underlying Durable Queues providercommandQueueName- Set the name of theDurableQueuesthat will be used queuing commands sent usingsendAndDontWait(Object)commandQueueRedeliveryPolicy- Set theRedeliveryPolicyused when handling queued commnds sent usingsendAndDontWait(Object)
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler)
Create a newDurableLocalCommandBususing defaults:- Parameters:
durableQueues- the underlying Durable Queues providersendAndDontWaitErrorHandler- Exception handler that will handle errors that occur duringCommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlyingDurableQueues
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler)
Create a newDurableLocalCommandBususing defaults:- Parameters:
durableQueues- the underlying Durable Queues providercommandQueueName- Set the name of theDurableQueuesthat will be used queuing commands sent usingsendAndDontWait(Object)sendAndDontWaitErrorHandler- Exception handler that will handle errors that occur duringCommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlyingDurableQueues
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, List<CommandBusInterceptor> interceptors)
Create a newDurableLocalCommandBususing defaults:- Parameters:
durableQueues- the underlying Durable Queues providerinterceptors- all theCommandBusInterceptor's
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, List<CommandBusInterceptor> interceptors)
Create a newDurableLocalCommandBususing defaults:- Parameters:
durableQueues- the underlying Durable Queues providercommandQueueName- Set the name of theDurableQueuesthat will be used queuing commands sent usingsendAndDontWait(Object)interceptors- all theCommandBusInterceptor's
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<CommandBusInterceptor> interceptors)
Create a newDurableLocalCommandBususing defaults:- Parameters:
durableQueues- the underlying Durable Queues providersendAndDontWaitErrorHandler- Exception handler that will handle errors that occur duringCommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlyingDurableQueuesinterceptors- all theCommandBusInterceptor's
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, int parallelSendAndDontWaitConsumers, QueueName commandQueueName, RedeliveryPolicy commandQueueRedeliveryPolicy, SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<CommandBusInterceptor> interceptors)
Create a newDurableLocalCommandBus- Parameters:
durableQueues- the underlying Durable Queues providerparallelSendAndDontWaitConsumers- How many parallelDurableQueuesconsumers should listen for messages added usingsendAndDontWait(Object)/sendAndDontWait(Object, Duration)commandQueueName- Set the name of theDurableQueuesthat will be used queuing commands sent usingsendAndDontWait(Object)commandQueueRedeliveryPolicy- Set theRedeliveryPolicyused when handling queued commnds sent usingsendAndDontWait(Object)sendAndDontWaitErrorHandler- Exception handler that will handle errors that occur duringCommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlyingDurableQueuesinterceptors- all theCommandBusInterceptor's
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<CommandBusInterceptor> interceptors)
Create a newDurableLocalCommandBususing defaults:- Parameters:
durableQueues- the underlying Durable Queues providercommandQueueName- {The strategy for selecting whichDurableQueuesQueueNameto use for a given combination of command and command handlersendAndDontWaitErrorHandler- Exception handler that will handle errors that occur duringCommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlyingDurableQueuesinterceptors- all theCommandBusInterceptor's
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, CommandBusInterceptor... interceptors)
Create a newDurableLocalCommandBususing defaults:- Parameters:
durableQueues- the underlying Durable Queues providerinterceptors- all theCommandBusInterceptor's
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, CommandBusInterceptor... interceptors)
Create a newDurableLocalCommandBususing defaults:- Parameters:
durableQueues- the underlying Durable Queues providercommandQueueName- {The strategy for selecting whichDurableQueuesQueueNameto use for a given combination of command and command handlerinterceptors- all theCommandBusInterceptor's
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, CommandBusInterceptor... interceptors)
Create a newDurableLocalCommandBususing defaults: using defaults:- Parameters:
durableQueues- the underlying Durable Queues providersendAndDontWaitErrorHandler- Exception handler that will handle errors that occur duringCommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlyingDurableQueuesinterceptors- all theCommandBusInterceptor's
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, int parallelSendAndDontWaitConsumers, QueueName commandQueueName, RedeliveryPolicy commandQueueRedeliveryPolicy, SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, CommandBusInterceptor... interceptors)
Create a newDurableLocalCommandBus- Parameters:
durableQueues- the underlying Durable Queues providerparallelSendAndDontWaitConsumers- How many parallelDurableQueuesconsumers should listen for messages added usingsendAndDontWait(Object)/sendAndDontWait(Object, Duration)commandQueueName- Set the name of theDurableQueuesthat will be used queuing commands sent usingsendAndDontWait(Object)commandQueueRedeliveryPolicy- Set theRedeliveryPolicyused when handling queued commnds sent usingsendAndDontWait(Object)sendAndDontWaitErrorHandler- Exception handler that will handle errors that occur duringCommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlyingDurableQueuesinterceptors- all theCommandBusInterceptor's
-
-
Method Detail
-
builder
public static DurableLocalCommandBusBuilder builder()
Builder for aDurableLocalCommandBusBuilder- Returns:
- builder for a
DurableLocalCommandBusBuilder
-
start
public void start()
Description copied from interface:LifecycleStart the processing. This operation must be idempotent, such that duplicate calls toLifecycle.start()for an already started process (whereLifecycle.isStarted()returns true) is ignored
-
stop
public void stop()
Description copied from interface:LifecycleStop the processing. This operation must be idempotent, such that duplicate calls toLifecycle.stop()for an already stopped process (whereLifecycle.isStarted()returns false) is ignored
-
isStarted
public boolean isStarted()
Description copied from interface:LifecycleReturns true if the process is started
-
sendAndDontWait
public <C> void sendAndDontWait(C command)
- Specified by:
sendAndDontWaitin interfaceCommandBus
-
sendAndDontWait
public <C> void sendAndDontWait(C command, Duration delayMessageDelivery)- Specified by:
sendAndDontWaitin interfaceCommandBus
-
getParallelSendAndDontWaitConsumers
public int getParallelSendAndDontWaitConsumers()
-
getCommandQueueName
public QueueName getCommandQueueName()
-
getCommandQueueRedeliveryPolicy
public RedeliveryPolicy getCommandQueueRedeliveryPolicy()
-
-