All Known Implementing Classes:
Inboxes.DurableQueueBasedInboxes

public interface Inboxes
The Inbox supports the transactional Store and Forward pattern from Enterprise Integration Patterns supporting At-Least-Once delivery guarantee.
The Inbox pattern is used to handle incoming messages from a message infrastructure (such as a Queue, Kafka, EventBus, etc).
The message is added to the Inbox in a transaction/UnitOfWork and afterwards the message is Acknowledged (ACK) with the message infrastructure the UnitOfWork is committed.
If the ACK fails then the message infrastructure will attempt to redeliver the message even if the UnitOfWork has been committed, since the message infrastructure and the Inbox don't share the same transactional resource. This means that messages received from the message infrastructure can be added more than once to the Inbox.
After the UnitOfWork has been committed, the messages will be asynchronously delivered to the message consumer in a new UnitOfWork.
The Inbox itself supports Message Redelivery in case the Message consumer experiences failures.
This means that the Message consumer, registered with the Inbox, can and will receive Messages more than once and therefore its message handling has to be idempotent.

If you're working with OrderedMessage's then the Inbox consumer must be configured with InboxConfig.getMessageConsumptionMode() having value MessageConsumptionMode.SingleGlobalConsumer in order to be able to guarantee that OrderedMessage's are delivered in OrderedMessage.getOrder() per OrderedMessage.getKey() across as many InboxConfig.numberOfParallelMessageConsumers as you wish to use.

  • Method Details

    • getOrCreateInbox

      Inbox getOrCreateInbox(InboxConfig inboxConfig)
      Get an existing Inbox instance or create a new instance. If an existing Inbox with a matching InboxName is already created then that instance is returned (irrespective of whether the redeliveryPolicy, etc. have the same values)
      Remember to call Outbox.consume(Consumer) to start consuming messages
      Parameters:
      inboxConfig - the inbox configuration
      Returns:
      the Inbox
    • getOrCreateInbox

      Inbox getOrCreateInbox(InboxConfig inboxConfig, Consumer<Message> messageConsumer)
      Get an existing Inbox instance or create a new instance. If an existing Inbox with a matching InboxName is already created then that instance is returned (irrespective of whether the redeliveryPolicy, etc. have the same values)
      Parameters:
      inboxConfig - the inbox configuration
      messageConsumer - the asynchronous message consumer. See PatternMatchingMessageHandler
      Returns:
      the Inbox
    • getOrCreateInbox

      default Inbox getOrCreateInbox(InboxConfig inboxConfig, dk.cloudcreate.essentials.reactive.command.CommandBus forwardTo)
      Get an existing Inbox instance or create a new instance. If an existing Inbox with a matching InboxName is already created then that instance is returned (irrespective of whether the redeliveryPolicy, etc. have the same values)
      Parameters:
      inboxConfig - the inbox configuration
      forwardTo - forward messages to this command bus using CommandBus.send(Object)
      Returns:
      the Inbox
    • getInboxes

      Collection<Inbox> getInboxes()
      Get all the Inbox instances managed by this Inboxes instance
      Returns:
      all the Inbox instances managed by this Inboxes instance
    • durableQueueBasedInboxes

      static Inboxes durableQueueBasedInboxes(DurableQueues durableQueues, FencedLockManager fencedLockManager)
      Create an Inboxes instance that uses a DurableQueues as its storage and message delivery mechanism.
      Parameters:
      durableQueues - The DurableQueues implementation used by the Inboxes instance returned
      fencedLockManager - the FencedLockManager used for Inbox's that use MessageConsumptionMode.SingleGlobalConsumer
      Returns:
      the Inboxes instance