Class IdempotentConsumerDefinition

  • All Implemented Interfaces:
    org.apache.camel.CamelContextAware, org.apache.camel.LineNumberAware, Block, HasExpressionType, OutputNode, org.apache.camel.NamedNode, org.apache.camel.spi.HasId, org.apache.camel.spi.IdAware

    @Metadata(label="eip,routing")
    public class IdempotentConsumerDefinition
    extends OutputExpressionNode
    Filters out duplicate messages
    • Constructor Detail

      • IdempotentConsumerDefinition

        public IdempotentConsumerDefinition()
      • IdempotentConsumerDefinition

        public IdempotentConsumerDefinition​(org.apache.camel.Expression messageIdExpression,
                                            org.apache.camel.spi.IdempotentRepository idempotentRepository)
    • Method Detail

      • getShortName

        public String getShortName()
      • getLabel

        public String getLabel()
        Description copied from class: ProcessorDefinition
        Returns a label to describe this node such as the expression if some kind of expression node
        Specified by:
        getLabel in interface org.apache.camel.NamedNode
        Overrides:
        getLabel in class ExpressionNode
      • idempotentRepository

        public IdempotentConsumerDefinition idempotentRepository​(String ref)
        Sets the reference name of the message id repository
        Parameters:
        ref - the reference name of message id repository
        Returns:
        builder
      • idempotentRepository

        public IdempotentConsumerDefinition idempotentRepository​(org.apache.camel.spi.IdempotentRepository idempotentRepository)
        Sets the message id repository for the idempotent consumer
        Parameters:
        idempotentRepository - the repository instance of idempotent
        Returns:
        builder
      • eager

        public IdempotentConsumerDefinition eager​(boolean eager)
        Sets whether to eagerly add the key to the idempotent repository or wait until the exchange is complete. Eager is default enabled.
        Parameters:
        eager - true to add the key before processing, false to wait until the exchange is complete.
        Returns:
        builder
      • completionEager

        public IdempotentConsumerDefinition completionEager​(boolean completionEager)
        Sets whether to complete the idempotent consumer eager or when the exchange is done.

        If this option is true to complete eager, then the idempotent consumer will trigger its completion when the exchange reached the end of the block of the idempotent consumer pattern. So if the exchange is continued routed after the block ends, then whatever happens there does not affect the state.

        If this option is false (default) to not complete eager, then the idempotent consumer will complete when the exchange is done being routed. So if the exchange is continued routed after the block ends, then whatever happens there also affect the state. For example if the exchange failed due to an exception, then the state of the idempotent consumer will be a rollback.

        Parameters:
        completionEager - whether to complete eager or complete when the exchange is done
        Returns:
        builder
      • removeOnFailure

        public IdempotentConsumerDefinition removeOnFailure​(boolean removeOnFailure)
        Sets whether to remove or keep the key on failure.

        The default behavior is to remove the key on failure.

        Parameters:
        removeOnFailure - true to remove the key, false to keep the key if the exchange fails.
        Returns:
        builder
      • skipDuplicate

        public IdempotentConsumerDefinition skipDuplicate​(boolean skipDuplicate)
        Sets whether to skip duplicates or not.

        The default behavior is to skip duplicates.

        A duplicate message would have the Exchange property Exchange.DUPLICATE_MESSAGE set to a Boolean.TRUE value. A none duplicate message will not have this property set.

        Parameters:
        skipDuplicate - true to skip duplicates, false to allow duplicates.
        Returns:
        builder
      • setExpression

        public void setExpression​(ExpressionDefinition expression)
        Expression used to calculate the correlation key to use for duplicate check. The Exchange which has the same correlation key is regarded as a duplicate and will be rejected.
        Overrides:
        setExpression in class ExpressionNode
      • getIdempotentRepositoryBean

        public org.apache.camel.spi.IdempotentRepository getIdempotentRepositoryBean()
      • getIdempotentRepository

        public String getIdempotentRepository()
      • setIdempotentRepository

        public void setIdempotentRepository​(String idempotentRepository)
      • setIdempotentRepository

        public void setIdempotentRepository​(org.apache.camel.spi.IdempotentRepository idempotentRepository)
      • getEager

        public String getEager()
      • setEager

        public void setEager​(String eager)
      • getSkipDuplicate

        public String getSkipDuplicate()
      • setSkipDuplicate

        public void setSkipDuplicate​(String skipDuplicate)
      • getRemoveOnFailure

        public String getRemoveOnFailure()
      • setRemoveOnFailure

        public void setRemoveOnFailure​(String removeOnFailure)
      • getCompletionEager

        public String getCompletionEager()
      • setCompletionEager

        public void setCompletionEager​(String completionEager)