SEDA,VM和Apache Camel中的direct有什么区别? [英] What is the difference between SEDA, VM and direct in Apache Camel?

查看:247
本文介绍了SEDA,VM和Apache Camel中的direct有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经与SEDA和Direct一起工作过,而且我还阅读了文档.

I had worked with both SEDA and direct, and I've also read the documentation.

但是我仍然无法想象SEDA和Direct的用法. Vm对我来说是新手.

But I still cannot visualize the usage of SEDA and direct. Vm is new to me.

请举例说明.

推荐答案

至少有四种不同的机制,一条骆驼路线可以将数据直接传递给另一条. 直接"是指不使用网络或某种形式的中间存储(文件,数据库).这些机制可以根据它们是否可以在CamelContext实例之间传递数据以及它们是同步还是异步来进行分组.

There are at least four different mechanisms by which one Camel route can directly pass data to another. By "directly" I mean without using a network or some form of intermediate storage (file, database). These mechanisms can be grouped according to whether they can pass data between CamelContext instances or not, and whether they are synchronous or asynchronous.

  • 直接-单个CamelContext,同步(块生产者)
  • SEDA-单个CamelContext,异步(不阻止生产者)
  • VM-多个CamelContext,异步(不阻止生产者)
  • direct-VM-多个CamelContext,同步的(块生产者)

直接和直接VM机制是同步的,从某种意义上说,生成方的端点一直阻塞到使用方的端点及其所有其余路由逻辑都完成为止. SEDA和VM机制都使用使用者上的线程池,因此,生产者发出的每个请求都分配给池中的线程之一.这样,消费者端点及其关联的路由逻辑可以独立于生产者进行操作.

The direct and direct-VM mechanisms are synchronous, in the sense that the producing endpoint blocks until the consuming endpoint, and all the rest of its routing logic, is complete. The SEDA and VM mechanisms both use a pool of threads on the consumer, such that each request made by the producer is assigned to one of the threads in the pool. This allows the consumer endpoint and its associated routing logic to act independently of the producer.

在不同的Camel上下文之间进行通信的情况下,都需要VM端点.在许多情况下,可以将路由合并到同一CamelContext中.但是,由于模块性的原因,有时它是不可取的,或者是不可能的,因为某些应用程序框架会这样做.例如,我可能会在库(或组件)中实现某些Camel路由逻辑,以期该库可被其他代码使用.为了完整起见,该库可能会定义具有各种路由的自包含CamelContext.如果要在库中调用Camel逻辑,则需要使用VM或Direct-VM,因为直接端点和SEDA端点不包含在Camel上下文之间路由所需的逻辑.

Both the VM endpoints are required in situations where communication is between different Camel contexts. In many cases it is possible to combine routes into the same CamelContext. However, it may sometimes be inadvisable, for reasons of modularity, or impossible, because some application framework makes it so. For example, I might implement some Camel routing logic in a library (or component) with the intention that the library be used by other code. To be complete, this library will probably define a self-contained CamelContext with various routes. If I want to invoke the Camel logic in the library, I will need to use VM or direct-VM, because direct and SEDA endpoints do not contain the logic needed to route between Camel contexts.

这篇关于SEDA,VM和Apache Camel中的direct有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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