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 sendAndDontWait(Object)/sendAndDontWait(Object, Duration)), variant of the CommandBus concept
Durability for sendAndDontWait(Object)/sendAndDontWait(Object, Duration)) is delegated to DurableQueues
Which 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 Details

    • DEFAULT_COMMAND_QUEUE_NAME

      public static final QueueName DEFAULT_COMMAND_QUEUE_NAME
    • DEFAULT_REDELIVERY_POLICY

      public static final RedeliveryPolicy DEFAULT_REDELIVERY_POLICY
  • Constructor Details

    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues)
      Create a new DurableLocalCommandBus using defaults:
      Parameters:
      durableQueues - the underlying Durable Queues provider
    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, RedeliveryPolicy commandQueueRedeliveryPolicy)
      Create a new DurableLocalCommandBus using defaults:
      • SendAndDontWaitErrorHandler: SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler
      Parameters:
      durableQueues - the underlying Durable Queues provider
      commandQueueName - Set the name of the DurableQueues that will be used queuing commands sent using sendAndDontWait(Object)
      commandQueueRedeliveryPolicy - Set the RedeliveryPolicy used when handling queued commnds sent usingsendAndDontWait(Object)
    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler)
      Parameters:
      durableQueues - the underlying Durable Queues provider
      sendAndDontWaitErrorHandler - Exception handler that will handle errors that occur during CommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlying DurableQueues
    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler)
      Create a new DurableLocalCommandBus using defaults:
      • SendAndDontWaitErrorHandler: SendAndDontWaitErrorHandler.RethrowingSendAndDontWaitErrorHandler
      Parameters:
      durableQueues - the underlying Durable Queues provider
      commandQueueName - Set the name of the DurableQueues that will be used queuing commands sent using sendAndDontWait(Object)
      sendAndDontWaitErrorHandler - Exception handler that will handle errors that occur during CommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlying DurableQueues
    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues, List<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors)
      Create a new DurableLocalCommandBus using defaults:
      Parameters:
      durableQueues - the underlying Durable Queues provider
      interceptors - all the CommandBusInterceptor's
    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, List<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors)
      Create a new DurableLocalCommandBus using defaults:
      Parameters:
      durableQueues - the underlying Durable Queues provider
      commandQueueName - Set the name of the DurableQueues that will be used queuing commands sent using sendAndDontWait(Object)
      interceptors - all the CommandBusInterceptor's
    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors)
      Parameters:
      durableQueues - the underlying Durable Queues provider
      sendAndDontWaitErrorHandler - Exception handler that will handle errors that occur during CommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlying DurableQueues
      interceptors - all the CommandBusInterceptor'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)
      Parameters:
      durableQueues - the underlying Durable Queues provider
      parallelSendAndDontWaitConsumers - How many parallel DurableQueues consumers should listen for messages added using sendAndDontWait(Object)/sendAndDontWait(Object, Duration)
      commandQueueName - Set the name of the DurableQueues that will be used queuing commands sent using sendAndDontWait(Object)
      commandQueueRedeliveryPolicy - Set the RedeliveryPolicy used when handling queued commnds sent usingsendAndDontWait(Object)
      sendAndDontWaitErrorHandler - Exception handler that will handle errors that occur during CommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlying DurableQueues
      interceptors - all the CommandBusInterceptor's
    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, List<dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor> interceptors)
      Parameters:
      durableQueues - the underlying Durable Queues provider
      commandQueueName - {The strategy for selecting which DurableQueues QueueName to use for a given combination of command and command handler
      sendAndDontWaitErrorHandler - Exception handler that will handle errors that occur during CommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlying DurableQueues
      interceptors - all the CommandBusInterceptor's
    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues, dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor... interceptors)
      Create a new DurableLocalCommandBus using defaults:
      Parameters:
      durableQueues - the underlying Durable Queues provider
      interceptors - all the CommandBusInterceptor's
    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues, QueueName commandQueueName, dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor... interceptors)
      Create a new DurableLocalCommandBus using defaults:
      Parameters:
      durableQueues - the underlying Durable Queues provider
      commandQueueName - {The strategy for selecting which DurableQueues QueueName to use for a given combination of command and command handler
      interceptors - all the CommandBusInterceptor's
    • DurableLocalCommandBus

      public DurableLocalCommandBus(DurableQueues durableQueues, dk.cloudcreate.essentials.reactive.command.SendAndDontWaitErrorHandler sendAndDontWaitErrorHandler, dk.cloudcreate.essentials.reactive.command.interceptor.CommandBusInterceptor... interceptors)
      Parameters:
      durableQueues - the underlying Durable Queues provider
      sendAndDontWaitErrorHandler - Exception handler that will handle errors that occur during CommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlying DurableQueues
      interceptors - all the CommandBusInterceptor'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)
      Parameters:
      durableQueues - the underlying Durable Queues provider
      parallelSendAndDontWaitConsumers - How many parallel DurableQueues consumers should listen for messages added using sendAndDontWait(Object)/sendAndDontWait(Object, Duration)
      commandQueueName - Set the name of the DurableQueues that will be used queuing commands sent using sendAndDontWait(Object)
      commandQueueRedeliveryPolicy - Set the RedeliveryPolicy used when handling queued commnds sent usingsendAndDontWait(Object)
      sendAndDontWaitErrorHandler - Exception handler that will handle errors that occur during CommandBus.sendAndDontWait(Object)/CommandBus.sendAndDontWait(Object, Duration). If this handler doesn't rethrow the exeption, then the message will not be retried by the underlying DurableQueues
      interceptors - all the CommandBusInterceptor's
  • Method Details

    • builder

      public static DurableLocalCommandBusBuilder builder()
      Returns:
      builder for a DurableLocalCommandBusBuilder
    • start

      public void start()
      Description copied from interface: Lifecycle
      Start the processing. This operation must be idempotent, such that duplicate calls to Lifecycle.start() for an already started process (where Lifecycle.isStarted() returns true) is ignored
      Specified by:
      start in interface Lifecycle
    • stop

      public void stop()
      Description copied from interface: Lifecycle
      Stop the processing. This operation must be idempotent, such that duplicate calls to Lifecycle.stop() for an already stopped process (where Lifecycle.isStarted() returns false) is ignored
      Specified by:
      stop in interface Lifecycle
    • isStarted

      public boolean isStarted()
      Description copied from interface: Lifecycle
      Returns true if the process is started
      Specified by:
      isStarted in interface Lifecycle
      Returns:
      true if the process is started otherwise false
    • sendAndDontWait

      public <C> void sendAndDontWait(C command)
      Specified by:
      sendAndDontWait in interface dk.cloudcreate.essentials.reactive.command.CommandBus
    • sendAndDontWait

      public <C> void sendAndDontWait(C command, Duration delayMessageDelivery)
      Specified by:
      sendAndDontWait in interface dk.cloudcreate.essentials.reactive.command.CommandBus
    • getParallelSendAndDontWaitConsumers

      public int getParallelSendAndDontWaitConsumers()
    • getCommandQueueName

      public QueueName getCommandQueueName()
    • getCommandQueueRedeliveryPolicy

      public RedeliveryPolicy getCommandQueueRedeliveryPolicy()