Class DefaultIdempotentMessageConsumptionService
java.lang.Object
com.broadleafcommerce.common.messaging.service.DefaultIdempotentMessageConsumptionService
- All Implemented Interfaces:
IdempotentMessageConsumptionService
public class DefaultIdempotentMessageConsumptionService
extends Object
implements IdempotentMessageConsumptionService
Service responsible for enforcing idempotency checks on a message before executing an operation
against the message.
- Author:
- Chris Kittrell (ckittrell)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final MessageLockService
protected MessageLockProperties
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultIdempotentMessageConsumptionService
(MessageLockService messageLockService) -
Method Summary
Modifier and TypeMethodDescription<T> void
consumeMessage
(org.springframework.messaging.Message<T> message, String listenerName, Consumer<org.springframework.messaging.Message<T>> operation) Executes the provided operation if the message's idempotency check passes.<T,
R> R consumeMessage
(org.springframework.messaging.Message<T> message, String listenerName, Function<org.springframework.messaging.Message<T>, R> operation) Executes the provided operation if the message's idempotency check passes.protected MessageLockService
void
setProperties
(MessageLockProperties properties) protected boolean
validateStatusAware
(String listenerName)
-
Field Details
-
messageLockService
-
properties
-
-
Constructor Details
-
DefaultIdempotentMessageConsumptionService
-
-
Method Details
-
consumeMessage
public <T> void consumeMessage(org.springframework.messaging.Message<T> message, String listenerName, Consumer<org.springframework.messaging.Message<T>> operation) Description copied from interface:IdempotentMessageConsumptionService
Executes the provided operation if the message's idempotency check passes. If the message fails the idempotency check, then we'll quietly return to the caller without executing the operation.- Specified by:
consumeMessage
in interfaceIdempotentMessageConsumptionService
- Parameters:
message
- The message that is to be processed.listenerName
- The name of the message listener. This value can be used to distinguish this message consumption from that of a different message listener.operation
- The operation that is to be executed, without a return value
-
consumeMessage
@Nullable public <T,R> R consumeMessage(org.springframework.messaging.Message<T> message, String listenerName, Function<org.springframework.messaging.Message<T>, R> operation) Description copied from interface:IdempotentMessageConsumptionService
Executes the provided operation if the message's idempotency check passes. If the message fails the idempotency check, then we'll returnnull
to the caller without executing the operation.- Specified by:
consumeMessage
in interfaceIdempotentMessageConsumptionService
- Parameters:
message
- The message that is to be processed.listenerName
- The name of the message listener. This value can be used to distinguish this message consumption from that of a different message listener.operation
- The operation that is to be executed, with a return value- Returns:
- The result of the operation
-
validateStatusAware
-
getMessageLockService
-
setProperties
-