Class DurableLocalCommandBus
java.lang.Object
dk.cloudcreate.essentials.reactive.command.AbstractCommandBus
dk.cloudcreate.essentials.components.foundation.reactive.command.DurableLocalCommandBus
- All Implemented Interfaces:
Lifecycle,dk.cloudcreate.essentials.reactive.command.CommandBus
public class DurableLocalCommandBus
extends dk.cloudcreate.essentials.reactive.command.AbstractCommandBus
implements Lifecycle
Provides a JVM local and durable,
in regard to
Durability for
Which
The
Note: If the
Due to this the
sendAndDontWait(Object)/sendAndDontWait(Object, Duration)),
variant of the CommandBus conceptDurability for
sendAndDontWait(Object)/sendAndDontWait(Object, Duration)) is delegated
to DurableQueuesWhich
QueueName that is used will be determined by the specified getCommandQueueName()The
RedeliveryPolicy is determined by the specified getCommandQueueRedeliveryPolicy()Note: If the
SendAndDontWaitErrorHandler provided doesn't rethrow the exception, then the underlying DurableQueues will not be able to retry the command.Due to this the
DurableLocalCommandBus defaults to using the SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler- See Also:
-
AnnotatedCommandHandler
-
Field Summary
FieldsFields inherited from class dk.cloudcreate.essentials.reactive.command.AbstractCommandBus
commandHandlers, commandTypeToCommandHandlerCache, interceptors, sendAndDontWaitErrorHandler -
Constructor Summary
ConstructorsConstructorDescriptionDurableLocalCommandBus(DurableQueues durableQueues) Create a newDurableLocalCommandBususing defaults:getCommandQueueName():DEFAULT_COMMAND_QUEUE_NAMEgetCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYSendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandlerDurableLocalCommandBus(DurableQueues durableQueues, int parallelSendAndDontWaitConsumers, QueueName commandQueueName, RedeliveryPolicy commandQueueRedeliveryPolicy, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor... interceptors) Create a newDurableLocalCommandBusDurableLocalCommandBus(DurableQueues durableQueues, int parallelSendAndDontWaitConsumers, QueueName commandQueueName, RedeliveryPolicy commandQueueRedeliveryPolicy, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors) Create a newDurableLocalCommandBusDurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, RedeliveryPolicy commandQueueRedeliveryPolicy) Create a newDurableLocalCommandBususing defaults:SendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandlerDurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor... interceptors) Create a newDurableLocalCommandBususing defaults:getCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYSendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandlerDurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler) Create a newDurableLocalCommandBususing defaults:SendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandlerDurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors) Create a newDurableLocalCommandBususing defaults:getCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYDurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, List<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors) Create a newDurableLocalCommandBususing defaults:getCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYSendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandlerDurableLocalCommandBus(DurableQueues durableQueues, dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor... interceptors) Create a newDurableLocalCommandBususing defaults:getCommandQueueName():DEFAULT_COMMAND_QUEUE_NAMEgetCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYSendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandlerDurableLocalCommandBus(DurableQueues durableQueues, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler) Create a newDurableLocalCommandBususing defaults:getCommandQueueName():DEFAULT_COMMAND_QUEUE_NAMEgetCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYDurableLocalCommandBus(DurableQueues durableQueues, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor... interceptors) Create a newDurableLocalCommandBususing defaults: using defaults:getCommandQueueName():DEFAULT_COMMAND_QUEUE_NAMEgetCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYDurableLocalCommandBus(DurableQueues durableQueues, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors) Create a newDurableLocalCommandBususing defaults:getCommandQueueName():DEFAULT_COMMAND_QUEUE_NAMEgetCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYDurableLocalCommandBus(DurableQueues durableQueues, List<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors) Create a newDurableLocalCommandBususing defaults:getCommandQueueName():DEFAULT_COMMAND_QUEUE_NAMEgetCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYSendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Builder for aDurableLocalCommandBusBuilderintbooleanReturns 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface dk.cloudcreate.essentials.reactive.command.CommandBus
addInterceptors
-
Field Details
-
DEFAULT_COMMAND_QUEUE_NAME
-
DEFAULT_REDELIVERY_POLICY
-
-
Constructor Details
-
DurableLocalCommandBus
Create a newDurableLocalCommandBususing defaults:getCommandQueueName():DEFAULT_COMMAND_QUEUE_NAMEgetCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYSendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler
- Parameters:
durableQueues- the underlying Durable Queues provider
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, RedeliveryPolicy commandQueueRedeliveryPolicy) Create a newDurableLocalCommandBususing defaults:SendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler
- 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, dk.cloudcreate.essentials.reactive.command.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, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler) Create a newDurableLocalCommandBususing defaults:SendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler
- 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<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors) Create a newDurableLocalCommandBususing defaults:getCommandQueueName():DEFAULT_COMMAND_QUEUE_NAMEgetCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYSendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler
- Parameters:
durableQueues- the underlying Durable Queues providerinterceptors- all theCommandBusInterceptor's
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, List<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors) Create a newDurableLocalCommandBususing defaults:getCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYSendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler
- 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, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<dk.cloudcreate.essentials.reactive.command.interceptor.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, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<dk.cloudcreate.essentials.reactive.command.interceptor.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, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<dk.cloudcreate.essentials.reactive.command.interceptor.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, dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor... interceptors) Create a newDurableLocalCommandBususing defaults:getCommandQueueName():DEFAULT_COMMAND_QUEUE_NAMEgetCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYSendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler
- Parameters:
durableQueues- the underlying Durable Queues providerinterceptors- all theCommandBusInterceptor's
-
DurableLocalCommandBus
public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor... interceptors) Create a newDurableLocalCommandBususing defaults:getCommandQueueRedeliveryPolicy():DEFAULT_REDELIVERY_POLICYSendAndDontWaitErrorHandler:SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler
- 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, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, dk.cloudcreate.essentials.reactive.command.interceptor.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, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, dk.cloudcreate.essentials.reactive.command.interceptor.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 Details
-
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 interfacedk.cloudcreate.essentials.reactive.command.CommandBus
-
sendAndDontWait
- Specified by:
sendAndDontWaitin interfacedk.cloudcreate.essentials.reactive.command.CommandBus
-
getParallelSendAndDontWaitConsumers
public int getParallelSendAndDontWaitConsumers() -
getCommandQueueName
-
getCommandQueueRedeliveryPolicy
-