Thread safety issues regarding access to the Exchange in Camel parallel processing

Solution Verified - Updated -

Issue

Consider a simple parallel splitter-aggregator route like the following; it splits a message body into parts, processes each part in parallel, and then recombines the parts into a single message using an aggregation strategy:

from ("...")
          .split (simple ("${body}"), new MyStrategy()).parallelProcessing()
         .to ("direct:process_part")
         .end()
         .to ("log://RESULT");

Each parallel branch will process its part of the message on a separate thread, as will the aggregator. Each thread will have access to an Exchange object, and all the data contained therein (e.g., Exchange properties), as will the aggregation methods. To what extent is this arrangement thread-safe? How are Exchange objects visible between processing threads, and between these threads and the aggregator?

Environment

  • Red Hat JBoss Fuse
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.