Interface IdempotentRepository

All Superinterfaces:
AutoCloseable, Service

public interface IdempotentRepository extends Service
Persistent store of message identifiers that implements the Idempotent Consumer pattern, ensuring each message is processed at most once.

The add and contains methods follow the Set contract: add(String) returns true only when the key is new (first occurrence), and contains(String) tests membership without adding.

The repository supports two processing modes, controlled by the Idempotent Consumer EIP configuration:

The removal-on-failure callback can be disabled via the EIP option, which is useful for at-most-once semantics even when the downstream processing fails. Persistent implementations backed by a file, JDBC database, Redis, or Hazelcast are available as separate Camel components.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(String key)
    Adds the key to the repository.
    default boolean
    add(Exchange exchange, String key)
    Adds the key to the repository.
    void
    Clear the repository.
    boolean
    Confirms the key, after the exchange has been processed successfully.
    default boolean
    confirm(Exchange exchange, String key)
    Confirms the key, after the exchange has been processed successfully.
    boolean
    Returns true if this repository contains the specified element.
    default boolean
    contains(Exchange exchange, String key)
    Returns true if this repository contains the specified element.
    boolean
    Removes the key from the repository.
    default boolean
    remove(Exchange exchange, String key)
    Removes the key from the repository.

    Methods inherited from interface Service

    build, close, init, start, stop
  • Method Details

    • add

      boolean add(String key)
      Adds the key to the repository.

      Important: Read the class javadoc about eager vs non-eager mode.

      Parameters:
      key - the key of the message for duplicate test
      Returns:
      true if this repository did not already contain the specified element
    • contains

      boolean contains(String key)
      Returns true if this repository contains the specified element.

      Important: Read the class javadoc about eager vs non-eager mode.

      Parameters:
      key - the key of the message
      Returns:
      true if this repository contains the specified element
    • remove

      boolean remove(String key)
      Removes the key from the repository.

      Is usually invoked if the exchange failed.

      Important: Read the class javadoc about eager vs non-eager mode.

      Parameters:
      key - the key of the message for duplicate test
      Returns:
      true if the key was removed
    • confirm

      boolean confirm(String key)
      Confirms the key, after the exchange has been processed successfully.

      Important: Read the class javadoc about eager vs non-eager mode.

      Parameters:
      key - the key of the message for duplicate test
      Returns:
      true if the key was confirmed
    • clear

      void clear()
      Clear the repository.

      Important: Read the class javadoc about eager vs non-eager mode.

    • add

      default boolean add(Exchange exchange, String key)
      Adds the key to the repository.

      Important: Read the class javadoc about eager vs non-eager mode.

      Parameters:
      key - the key of the message for duplicate test
      Returns:
      true if this repository did not already contain the specified element
    • contains

      default boolean contains(Exchange exchange, String key)
      Returns true if this repository contains the specified element.

      Important: Read the class javadoc about eager vs non-eager mode.

      Parameters:
      key - the key of the message
      Returns:
      true if this repository contains the specified element
    • remove

      default boolean remove(Exchange exchange, String key)
      Removes the key from the repository.

      Is usually invoked if the exchange failed.

      Important: Read the class javadoc about eager vs non-eager mode.

      Parameters:
      key - the key of the message for duplicate test
      Returns:
      true if the key was removed
    • confirm

      default boolean confirm(Exchange exchange, String key)
      Confirms the key, after the exchange has been processed successfully.

      Important: Read the class javadoc about eager vs non-eager mode.

      Parameters:
      key - the key of the message for duplicate test
      Returns:
      true if the key was confirmed