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

camel-core / camel-bean - Dynamic router instances pass messages to wrong endpoints with @DynamicRouter annotation



    • Moderate


      This is actually reopening CAMEL-9311, because DynamicRouterConcurrentPOJOTest that was added to reproduce it is still failing.

      First I thought the test is just flaky due to its bad design: it was calling assertMockEndpointsSatisfied() without any synchronizations of the participating threads.

      But fixing that by adding


      and replacing assertMockEndpointsSatisfied() with some timeouted variant did not make the issue disappear.
      The improved reproducer test can be seen in this branch: https://github.com/ppalaga/camel/commits/CAMEL-19487

      Note that it is not always failing. On my machine, I see it failing like 1:10. Invoking it in a loop eventually leads to a failure:

      git fetch git@github.com:ppalaga/camel.git CAMEL-19487 
      git checkout -b CAMEL-19487 FETCH_HEAD
      # rebuild the tree
      mvnd clean install -Pfastinstall
      cd core/camel-core
      set -e; while true; do mvnd test -Dtest=DynamicRouterConcurrentPOJOTest#testConcurrentDynamicRouter; done

      The second commit https://github.com/ppalaga/camel/commits/CAMEL-19487 adds some debug output.
      In case of failure it shows that one of the dynamic router instances sometimes sends one or more messages to the wrong endpoint.
      Here is an example:

      [INFO] Running org.apache.camel.processor.dynamicrouter.DynamicRouterConcurrentPOJOTest
      [INFO] [stdout] ==== pipe a before Message from seda:a 74
      [INFO] [stdout] ======= adding to mock:b: Message from seda:a 74
      [INFO] [stdout] ==== pipe a after Message from seda:a 74 cnt 74
      [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.328 s <<< FAILURE! -- in org.apache.camel.processor.dynamicrouter.DynamicRouterConcurrentPOJOTest
      [ERROR] org.apache.camel.processor.dynamicrouter.DynamicRouterConcurrentPOJOTest.testConcurrentDynamicRouter -- Time elapsed: 0.317 s <<< FAILURE!
      [Expected mock:b to contain only messages from seda:b, but there were also messages from seda:a] 
      Expecting empty but was: ["Message from seda:a 74"]

      In this case the dynamic router instance attached to route a sends the message to mock:b.
      I'd say that's a serious bug.

      This is exactly what the original issue CAMEL-9311 was about.

      The issue does not occur when each route uses a different dynamic router type: when I copy MyDynamicRouterPojo as MyDynamicRouterPojoB and use it in the route b, then all works as expected.


        Issue Links



              davsclaus Claus Ibsen
              ppalaga Peter Palaga
              0 Vote for this issue
              3 Start watching this issue