Interface OutboxService
- All Superinterfaces:
Service
The following applies when using the outbox: - The outbox message is stored in the outbox. - If the transaction fails, the outbox message is not stored in the outbox and is never emitted. - A persisted outbox message is emitted eventually (asynchronously or synchronously, depending on the outbox implementation)
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<A extends Service>
AReturns a wrapper around the given service that executes asynchronously by submitting all events to this outbox instance.<S extends Service>
Soutboxed(S service) Returns a wrapper around the given service that executes asynchronously by submitting all events to this outbox instance.voidsubmit(String outboxEvent, OutboxMessage message) Stores the givenOutboxMessageunder the given outbox event in the outbox.static <S extends Service>
Sunboxed(S service) Returns the underlying service of the outbox wrapped service.
-
Field Details
-
PERSISTENT_ORDERED_NAME
- See Also:
-
PERSISTENT_UNORDERED_NAME
- See Also:
-
INMEMORY_NAME
- See Also:
-
-
Method Details
-
unboxed
Returns the underlying service of the outbox wrapped service. The returned service instance is the underlying outbox-independent instance executing synchronously.- Type Parameters:
S- the type of service- Parameters:
service- the service to unwrap from outbox wrapping- Returns:
- the underlying service of the outbox wrapped service.
-
submit
Stores the givenOutboxMessageunder the given outbox event in the outbox.- Parameters:
outboxEvent- the outbox event with which the message is stored and again published by theOutboxServicemessage- theOutboxMessagestored and again published by theOutboxService
-
outboxed
Returns a wrapper around the given service that executes asynchronously by submitting all events to this outbox instance. The returned instance can be cached, reused and is thread-safe.If the passed service is already wrapped with this outbox, the passed service is returned. If the passed service is wrapped by another outbox, a new wrapper for the underlying service is returned.
- Type Parameters:
S- the type of service- Parameters:
service- the service to be outboxed- Returns:
- a wrapper around the given service that executes asynchronously by submitting all events to this outbox instance.
-
outboxed
Returns a wrapper around the given service that executes asynchronously by submitting all events to this outbox instance. The returned instance can be cached, reused and is thread-safe.The given service is wrapped with an asynchronous interface, matching the original interface of the service, but providing all methods with a
voidreturn type. SeeAsyncCqnServicefor an example.If the passed service is already wrapped with this outbox, the passed service is returned. If the passed service is wrapped by another outbox, a new wrapper for the underlying service is returned.
- Type Parameters:
A- the type of the async interface- Parameters:
service- the service to be outboxedasyncInterface- the class of the async interface- Returns:
- a wrapper around the given service that executes asynchronously by submitting all events to this outbox instance.
-