骆驼是否为每条路线创建一个线程 [英] Does camel create a thread for each route

查看:27
本文介绍了骆驼是否为每条路线创建一个线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我开始使用骆驼,我发现它可能满足我的很多集成层需求.

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

我创建了一个 java 客户端应用程序(不在任何容器中运行),我在其中定义了两条路由:

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

route1:将文件从传入的文件夹 1 移动到文件夹 2

route1: move a file from an incoming folder1 to folder2

route2:将文件内容从 folderx 移动到 mq 队列.

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.

推荐答案

这取决于你在路由中使用的组件、正在创建和使用的线程数.

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

以及 Camel 中的一些 EIP 支持多线程(线程池),因此可以配置为使用 N 个线程.

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

在您的示例中,它是文件组件,它使用单个线程.由于您有 2 条路线,因此您将使用 2 个线程.一些组件还允许配置它们的线程(例如线程池).例如,最近我们在 Camel 2.10 中添加了对文件组件的支持(请参阅 https://camel.apache.org/components/latest/file-component.html)

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)

这里有一些关于 Camel 线程模型的说明http://camel.apache.org/threading-model.html

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

这篇关于骆驼是否为每条路线创建一个线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆