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
Fields Modifier and Type Field Description protected MessageLockService
messageLockService
-
Constructor Summary
Constructors Constructor Description DefaultIdempotentMessageConsumptionService(MessageLockService messageLockService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <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>
RconsumeMessage(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
getMessageLockService()
-
-
-
Field Detail
-
messageLockService
protected final MessageLockService messageLockService
-
-
Constructor Detail
-
DefaultIdempotentMessageConsumptionService
public DefaultIdempotentMessageConsumptionService(MessageLockService messageLockService)
-
-
Method Detail
-
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
-
getMessageLockService
protected MessageLockService getMessageLockService()
-
-