Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does camel create a thread for each route

Recently i have started using camel and i see that it potentially addresses a lot of my integration layer needs.

I have created a java client application (not running in any container) where i defined two routes:

route1: move a file from an incoming folder1 to folder2

route2: move file content from folderx to mq queue.

I start my application and these routes are doing their job polling those folders and routing messages accordingly.

Can anyone explain me how the routes work. Does camel(context) create a thread for each route. What exactly happens?

Note: I could not find a straightforward notes on this on the camel site.

like image 529
techuser soma Avatar asked Aug 27 '12 21:08

techuser soma


People also ask

How does a Camel route work?

A Camel route is where the integration flow is defined. For example to integrate two systems then a Camel route can be coded to specify how these systems are integrated. An example could be to take files from a FTP server and send to a ActiveMQ messaging system.

Are Camel routes thread safe?

Everything else in Camel is thread safe and there is no way to tell Camel be thread safe if processor implementation is not. Save this answer.

What is Camel thread?

The threading model in Camel is based on a pluggable reactive routing engine, and thread pools from the JDK concurrency API. This page focuses on thread pools. Camel leverages thread pools in several places such as: Several EIP patterns support using thread pools for concurrency.

What is dynamic routing in Camel?

The Dynamic Router from the EIP patterns allows you to route messages while avoiding the dependency of the router on all possible destinations while maintaining its efficiency.


1 Answers

It depends on the components you use in the routes, how many threads are being created and used.

As well as some EIPs in Camel supports multiple threads (thread pools) and thus can be configured to use N number of threads.

In your example its the file component, and it uses a single thread. As you have 2 routes, you will then use 2 threads. Some components also allows to configure their threading (eg thread pools). For example recently we added support for that for the file component in Camel 2.10 (see the scheduledExecutorService option at https://camel.apache.org/components/latest/file-component.html)

There is some notes here about Camel threading model http://camel.apache.org/threading-model.html

like image 90
Claus Ibsen Avatar answered Oct 24 '22 03:10

Claus Ibsen