Interface Inboxes
- All Known Implementing Classes:
Inboxes.DurableQueueBasedInboxes
public interface Inboxes
The
The
The message is added to the
If the ACK fails then the message infrastructure will attempt to redeliver the message even if the
After the
The
This means that the Message consumer, registered with 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.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic InboxesdurableQueueBasedInboxes(DurableQueues durableQueues, FencedLockManager fencedLockManager) Create anInboxesinstance that uses aDurableQueuesas its storage and message delivery mechanism.getOrCreateInbox(InboxConfig inboxConfig) Get an existingInboxinstance or create a new instance.default InboxgetOrCreateInbox(InboxConfig inboxConfig, dk.cloudcreate.essentials.reactive.command.CommandBus forwardTo) Get an existingInboxinstance or create a new instance.getOrCreateInbox(InboxConfig inboxConfig, Consumer<Message> messageConsumer) Get an existingInboxinstance or create a new instance.
-
Method Details
-
getOrCreateInbox
Get an existingInboxinstance or create a new instance. If an existingInboxwith a matchingInboxNameis already created then that instance is returned (irrespective of whether the redeliveryPolicy, etc. have the same values)
Remember to callOutbox.consume(Consumer)to start consuming messages- Parameters:
inboxConfig- the inbox configuration- Returns:
- the
Inbox
-
getOrCreateInbox
Get an existingInboxinstance or create a new instance. If an existingInboxwith a matchingInboxNameis already created then that instance is returned (irrespective of whether the redeliveryPolicy, etc. have the same values)- Parameters:
inboxConfig- the inbox configurationmessageConsumer- the asynchronous message consumer. SeePatternMatchingMessageHandler- Returns:
- the
Inbox
-
getOrCreateInbox
default Inbox getOrCreateInbox(InboxConfig inboxConfig, dk.cloudcreate.essentials.reactive.command.CommandBus forwardTo) Get an existingInboxinstance or create a new instance. If an existingInboxwith a matchingInboxNameis already created then that instance is returned (irrespective of whether the redeliveryPolicy, etc. have the same values)- Parameters:
inboxConfig- the inbox configurationforwardTo- forward messages to this command bus usingCommandBus.send(Object)- Returns:
- the
Inbox
-
getInboxes
Collection<Inbox> getInboxes() -
durableQueueBasedInboxes
static Inboxes durableQueueBasedInboxes(DurableQueues durableQueues, FencedLockManager fencedLockManager) Create anInboxesinstance that uses aDurableQueuesas its storage and message delivery mechanism.- Parameters:
durableQueues- TheDurableQueuesimplementation used by theInboxesinstance returnedfencedLockManager- theFencedLockManagerused forInbox's that useMessageConsumptionMode.SingleGlobalConsumer- Returns:
- the
Inboxesinstance
-