Class BatchingHandlerRepository
java.lang.Object
io.fluxcapacitor.javaclient.modeling.BatchingHandlerRepository
- All Implemented Interfaces:
HandlerRepository
A batching wrapper for
HandlerRepository
that delays persistence operations until the end of the current
message batch.
This implementation is intended for use with @Stateful(commitInBatch = true)
handlers. It buffers all put()
and delete()
calls and flushes them via
DocumentStore.bulkUpdate(java.util.Collection<? extends io.fluxcapacitor.common.api.search.BulkUpdate>)
once batch processing completes.
Association lookups during batch processing always take into account:
- The persisted state (from the backing repository), and
- The in-memory cache of batch-local updates (created, updated, or deleted handlers) that have not been committed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Represents a buffered update to a handler instance (either index or delete). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRemoves the handler instance identified by the given ID from the repository.Collection
<? extends Entry<?>> findByAssociation
(Map<Object, String> associations) Finds all handler instances that match the given set of associations.protected void
Collection
<? extends Entry<?>> getAll()
Retrieves all currently stored handler instances.Persists or updates the handler instance identified by the given ID.removeOutdatedValues
(Collection<? extends Entry<?>> delegateResult) protected Map
<Object, BatchingHandlerRepository.Update> updates()
-
Constructor Details
-
BatchingHandlerRepository
public BatchingHandlerRepository()
-
-
Method Details
-
findByAssociation
Description copied from interface:HandlerRepository
Finds all handler instances that match the given set of associations.The association map typically represents values extracted from incoming messages (e.g., correlation keys) and will be matched against fields or methods annotated with
@Association
in registered handler instances.- Specified by:
findByAssociation
in interfaceHandlerRepository
- Parameters:
associations
- a map of association values, where the key is the value to match and the value is the corresponding property name or path (e.g.foo/bar/name
) in the handler- Returns:
- a collection of entries representing matching handler instances
-
getAll
Description copied from interface:HandlerRepository
Retrieves all currently stored handler instances.- Specified by:
getAll
in interfaceHandlerRepository
- Returns:
- a collection of all known handler entries
-
removeOutdatedValues
protected Stream<? extends Entry<?>> removeOutdatedValues(Collection<? extends Entry<?>> delegateResult) -
put
Description copied from interface:HandlerRepository
Persists or updates the handler instance identified by the given ID.- Specified by:
put
in interfaceHandlerRepository
- Parameters:
id
- the unique identifier for the handler instancevalue
- the handler instance to persist- Returns:
- a future that completes when the operation has finished
-
delete
Description copied from interface:HandlerRepository
Removes the handler instance identified by the given ID from the repository.- Specified by:
delete
in interfaceHandlerRepository
- Parameters:
id
- the identifier of the handler instance to delete- Returns:
- a future that completes when the deletion has finished
-
updates
-
flushUpdates
-