Class BatchingHandlerRepository

java.lang.Object
io.fluxcapacitor.javaclient.modeling.BatchingHandlerRepository
All Implemented Interfaces:
HandlerRepository

public class BatchingHandlerRepository extends Object implements 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.
  • Constructor Details

    • BatchingHandlerRepository

      public BatchingHandlerRepository()
  • Method Details

    • findByAssociation

      public Collection<? extends Entry<?>> findByAssociation(Map<Object,String> associations)
      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 interface HandlerRepository
      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

      public Collection<? extends Entry<?>> getAll()
      Description copied from interface: HandlerRepository
      Retrieves all currently stored handler instances.
      Specified by:
      getAll in interface HandlerRepository
      Returns:
      a collection of all known handler entries
    • removeOutdatedValues

      protected Stream<? extends Entry<?>> removeOutdatedValues(Collection<? extends Entry<?>> delegateResult)
    • put

      public CompletableFuture<?> put(Object id, Object value)
      Description copied from interface: HandlerRepository
      Persists or updates the handler instance identified by the given ID.
      Specified by:
      put in interface HandlerRepository
      Parameters:
      id - the unique identifier for the handler instance
      value - the handler instance to persist
      Returns:
      a future that completes when the operation has finished
    • delete

      public CompletableFuture<?> delete(Object id)
      Description copied from interface: HandlerRepository
      Removes the handler instance identified by the given ID from the repository.
      Specified by:
      delete in interface HandlerRepository
      Parameters:
      id - the identifier of the handler instance to delete
      Returns:
      a future that completes when the deletion has finished
    • updates

    • flushUpdates

      protected void flushUpdates(Map<Object,BatchingHandlerRepository.Update> map)