13 Parallel processing

 

This chapter covers

  • Camel’s threading model
  • Configuring thread pools and thread profiles
  • Using concurrency with EIPs
  • Handling scalability with Camel
  • Writing asynchronous Camel components

Concurrency is another word for multitasking, and we multitask all the time in our daily lives. We put the coffee on, and while it brews, we grab the tablet and glance at the morning news while we eagerly wait for the coffee to be ready. Computers are also capable of doing multiple tasks—you may have multiple tabs open in your web browser while your mail application is fetching new email, for example.

Juggling multiple tasks is also common in enterprise systems, such as when you’re processing incoming orders, handling invoices, and doing inventory management, and these demands only grow over time. With concurrency, you can achieve higher performance; by executing in parallel, you can get more work done in less time.

Camel processes multiple messages concurrently in Camel routes, and it uses the concurrency features from Java, so we’ll first discuss how concurrency works in Java before moving on to how thread pools work and how you define and use them in Camel. The thread pool is the mechanism in Java that orchestrates multiple tasks. After we’ve discussed thread pools, we’ll move on to using concurrency with the EIPs.

13.1 Introducing concurrency

13.1.1 Running the example without concurrency

13.1.2 Using concurrency

13.2 Using thread pools

13.2.1 Understanding thread pools in Java

13.2.2 Using Camel thread pool profiles

13.2.3 Creating custom thread pools

13.2.4 Using ExecutorServiceManager

13.3 Parallel processing with EIPs

13.3.1 Using concurrency with the Threads EIP

13.3.2 Using concurrency with the Multicast EIP

13.3.3 Using concurrency with the Wire Tap EIP

13.4 Using the asynchronous routing engine

13.4.1 Hitting the scalability limit

13.4.2 Scalability in Camel

13.4.3 Components supporting asynchronous processing

13.4.4 Asynchronous API

13.4.5 Writing a custom asynchronous component

13.4.6 Potential issues when using an asynchronous component

13.5 Summary and best practices

sitemap