Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-1650

Race condition in IdempotentConsumer

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-M1
    • 2.0-M2
    • camel-core
    • None

    Description

      A possible possible race condition exists in the IdempotentConsumer implementation:
      The code first checks in the MessageIdRepository if the message was already processed. If not then it processes the message and
      afterwards adds the id to the repository. (See also http://issues.apache.org/activemq/browse/CAMEL-1451). There is no locking
      between the check with "contains" and the insert with "add". So if multiple threads/instances try this in parallel for the same id, then
      it might happen that more than one finds the id not yet contained in the repository and the same message is processed multiple
      times.

      I enclose an extended version of IdempotentConsumerTest which illustrates the problem.
      It is important to note that even if the test demonstrates the issue with an MemoryIdempotentRepository a solution should also
      address the case of a database based respository in a clustered environment. So this might imply that some locking mechanism on the
      database is required.

      Attachments

        1. IdempotentConsumerTest.java
          6 kB
          Oliver Hecker

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              ohecker Oliver Hecker
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: