I need to implement the idempotent consumer pattern in Camel (2.23.0) and was looking at possible implementations. Currently, I am only able to implement either the JdbcMessageIdRepository or JpaMessageIdRepository and was wondering if these implementations are thread-safe when handling concurrent requests? I inspected the source code of these classes in the Camel Github, but could not find any code preventing/handling concurrent access.
Can anybody confirm this? Thx very much!
Short Answer: Yes (on DB table with primary key)
Long answer: I tried it out today (using the Parallel Controller plugin of JMeter) and noticed that if I don't set a primary key on the CAMEL_MESSAGEPROCESSED
table, I get duplicate entries when firing multiple simultaneous HTTP-requests. However, if I add a primary key to this table (as also recommended by the camel docs) the idempotent
consumer acts as expected.
Is it safe to say that synchronization is taken care of by the primary key mechanism on the table?
I mean, only one Request-thread
succeeds in adding a row to the CAMEL_MESSAGEPROCESSED
table and from what I've observed during my tests is that the other Request
are marked as duplicate by
Camel (exchangeProperty(Exchange.DUPLICATE_MESSAGE)=true)