[
https://issues.apache.org/jira/browse/CAMEL-16078?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17271677#comment-17271677
]
Jeremy Ross commented on CAMEL-16078:
-------------------------------------
I believe Caffeine's Window TinyLfu algorithm is the culprit here. If I exclude
camel-caffeine-lrucache, the SimpleLRUCache is used, which seems to have a
strict policy of eldest entry is removed. Considering the importance of
idempotency and "once and only once" semantics, this is a far more preferable
algorithm, even if it's not designed for massive scale.
Considering that Caffeine's LRU cache can drop entries almost as soon as
they're added, I don't see this as an appropriate backing for
MemoryIdempotencyRepository, unless perhaps if the use case is massive scale,
and it's ok if some duplicate messages get through as long as performance is
good. Overall, to me, this behavior violates the [Principle of Least
Surprise|https://en.wikipedia.org/wiki/Principle_of_least_astonishment]. We
might consider, if nothing else, documenting this behavior. Long term it may be
better to find a backing that can truly support idempotency. Hoping others can
weigh in as I haven't used this part of Camel much.
I'm also curious if excluding camel-caffeine-lrucache has any other side
effects for other parts of camel.
> IdempotentConsumer + MemoryIdempotentRepository allows duplicates
> -----------------------------------------------------------------
>
> Key: CAMEL-16078
> URL: https://issues.apache.org/jira/browse/CAMEL-16078
> Project: Camel
> Issue Type: Bug
> Components: came-core
> Affects Versions: 3.7.1
> Reporter: Jeremy Ross
> Priority: Major
>
> In certain scenarios, it seems that IdempotentConsumer is allowing duplicate
> message to pass. In the test case below, with a cache size of 50, duplicate
> message within a few messages of each other are allowed to pass.
> Test case: https://gist.github.com/jeremyross/d76f658767b4f476f93a12f9067ed515
--
This message was sent by Atlassian Jira
(v8.3.4#803005)