-
- All Implemented Interfaces:
public final class TransactionBatcherHolds logic to apply batching, deduplication and caching of BatchableTransaction if no TransactionBatcherCache implementation is provided it will use DefaultTransactionBatcherCache
-
-
Field Summary
Fields Modifier and Type Field Description private final ConcurrentHashMap<KClass<out TriggeredPublisher<Object, Object>>, TriggeredPublisherTransactions>batch
-
Constructor Summary
Constructors Constructor Description TransactionBatcher(TransactionBatcherCache cache)
-
Method Summary
Modifier and Type Method Description final ConcurrentHashMap<KClass<out TriggeredPublisher<Object, Object>>, TriggeredPublisherTransactions>getBatch()final <TInput extends Any, TOutput extends Any> CompletableFuture<TOutput>batch(TInput input, String transactionKey, TriggeredPublisher<TInput, TOutput> triggeredPublisher)adds a transaction input to the batch along with the triggeredPublisher instance that will receive the BatchableTransaction deduplication will be based on transactionKey which by default is the toString() representation of input batching will be based on the implementation of TriggeredPublisher this method returns a reference to a CompletableFuture which is a field of the BatchableTransaction that was just added into the queue final Unitdispatch()Trigger concurrently and asynchronously the instances of TriggeredPublisher that the batch holds at the end clear the queue -
-
Constructor Detail
-
TransactionBatcher
TransactionBatcher(TransactionBatcherCache cache)
-
-
Method Detail
-
getBatch
final ConcurrentHashMap<KClass<out TriggeredPublisher<Object, Object>>, TriggeredPublisherTransactions> getBatch()
-
batch
final <TInput extends Any, TOutput extends Any> CompletableFuture<TOutput> batch(TInput input, String transactionKey, TriggeredPublisher<TInput, TOutput> triggeredPublisher)
adds a transaction input to the batch along with the triggeredPublisher instance that will receive the BatchableTransaction deduplication will be based on transactionKey which by default is the toString() representation of input batching will be based on the implementation of TriggeredPublisher this method returns a reference to a CompletableFuture which is a field of the BatchableTransaction that was just added into the queue
-
dispatch
@Synchronized() final Unit dispatch()
Trigger concurrently and asynchronously the instances of TriggeredPublisher that the batch holds at the end clear the queue
-
-
-
-