骆驼路线和终点

发布于 2024-12-09 06:30:14 字数 882 浏览 1 评论 0原文

我一直在仔细研究 Apache Camel 文档,试图具体了解其两个最基本的概念(端点和路由),尽管这些术语在整个文档中随处可见,但我可以发现没有参考文献实际定义它们是什么以及它们的用途。尽管它们的名字听起来相当明显,而且我认为我明白它们是什么,但我现在被分配到一项让我深深陷入 Apache Camel Land 的任务,而且它绝对是至关重要的是我了解这些机制是什么。

我的猜测是,“端点”只是一个 bean - 可以像其他任何 bean 一样在配置文件中配置 - 将名称映射到 URI/端口组合(这取自 W3C 文档)。在 Apache Camel 的上下文中,我的猜测是端点用于将组件连接在一起,以便可以在它们之间形成“路由”(连接/映射)。因此,当位于端点 1 的组件 A 想要与位于端点 2 的组件 B 通信时,只要存在从 1 到 2 的映射,Camel 就能够在两者之间传输消息。

如果我错了,请阻止我并纠正我!

所以现在,我已经看到了看起来可以在 Java 中配置路由的示例:

from("endpointA").routeId("someMessage").to("endpointB");

并且我已经看到了看起来可以在 Java 中配置路由的示例 :在 XML 中配置:

<route id="">
    <from .../>
    <to .../>
</route>

这两种配置路由的方法,还是完全不同的概念?

最后,可以在端点之间路由的消息的格式是什么?例如,如果必须是 XML,那么这些路由消息的 XSD/架构是什么?如果它必须是 Java 对象,那么 Camel 可以发送的对象有哪些边界/限制?

I've been poring over the Apache Camel docs trying to get a concrete understanding of two of its most basic concepts (endpoints and routes), and although these terms are used everywhere throughout the docs, I can find no reference that actually defines what they are and what they are used for. And although their names are fairly obvious-sounding, and I think I understand what they are, I've now been assigned to a task that has landed me neck-deep in Apache Camel Land, and its absolutely vital that I understand what these mechanisms are.

My guess is that an "endpoint" is just a bean - one that can be configured in a config file like any other - that maps a name to a URI/port combo (this taken from the W3C docs). In the context of Apache Camel, my guess is that endpoints are used to connect components together, so that "routes" (connections/maps) can be formed between them. So when Component A living at Endpoint 1 wants to communicate with Component B living at Endpoint 2, so long as there is a mapping from 1 to 2, Camel will be able to transmit messages between these two.

Please stop me and correct me if I am wrong here!

So now, I've seen examples where it looks like routes can be configured in Java:

from("endpointA").routeId("someMessage").to("endpointB");

And I've seen examples where it looks like routes can be configured in XML:

<route id="">
    <from .../>
    <to .../>
</route>

Are these two methods for configuring routes, or are they different concepts altogether?

Finally, what is the format of the messages that can be routed between endpoints? If it has to be XML, for example, what is the XSD/schema of these routed messages? If it has to be a Java object, what bounds/restrictions apply to the objects that Camel can send?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

强辩 2024-12-16 06:30:14

看来您已经很好地掌握了这个概念。
我认为用更抽象的术语来思考端点是有帮助的。 camel 文档 在这里没有太大帮助。端点可以被认为是组件的接口。每个组件可以配置 1 个或多个端点。它帮助我在路线的上下文中思考端点。一个简单的路由可以从端点 A(这可以是 JMS 队列、tcp 套接字、文件或任何骆驼组件)前往端点 B(可以是任何骆驼组件)。当然,您也可以在路径中使用处理器来转换数据。

您给出的两个创建路线的示例只是创建路线的两种方法。它们是同一概念的示例。第一个是 Java DSL,第二个使用 XML。

消息的格式通常是 XML,并且 XML 可以是任何有效的 XML,并且不需要绑定到 XSD。该消息也可以是任何 Java 对象。只要它保留在 JVM 中(即不通过套接字),它就不需要可序列化。

It seems like you are getting a decent grasp of the concept.
I think it helps to think about endpoints in more abstract terms. The camel documentation is not much help here. Endpoints can be thought of as interfaces to a component. Each component can have 1 or more endpoints configured. It helps me to think about endpoints within the context of a route. A simple route can go from Endpoint A (This could be a JMS Queue, tcp socket, file or any camel component) and go to Endpoint B (which can be any camel component). You can of course have processors in the route too that transform the data.

The two examples of route creation you give are just that, two ways to create a route. They are the examples of the same concept. The first being Java DSL and the second using XML.

The format of the messages is typically XML, and the XML can be any valid XML and does not need to be tied to an XSD. The message can also be any Java object. As long as it is staying in the JVM (ie, not going over a socket) it doesn't need to be serializeable.

梦醒时光 2024-12-16 06:30:14

路由是处理步骤的有序组合

端点代表路由的开始或结束(在大多数情况下),其他路由可能连接到作为其开始/结束或可能返回到外部系统(例如JMS、电子邮件等)。 )

Route is an ordered combination of processing steps

Endpoint represents the beginning or end of a route (for the most part), that other routes might connect to as their beginning/end or might back onto an external system (e.g. JMS, email, etc.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文