骆驼路线和端点 [英] Camel Routes and Endpoints

查看:43
本文介绍了骆驼路线和端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在仔细阅读 Apache Camel 文档,试图具体了解其两个最基本概念(端点和路由),尽管这些术语在整个文档中随处可见,我找不到真正定义它们是什么以及它们用于什么的参考.尽管他们的名字听起来很明显,而且我认为我明白他们是什么,但我现在被分配到一项任务,这让我深深地陷入了 Apache Camel Land,而且绝对是我了解这些机制是什么至关重要.

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.

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

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.

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

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

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

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

而且我已经看到一些示例,它看起来可以在 XML 中配置路由:

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?

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

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?

推荐答案

您似乎对这个概念有了很好的理解.我认为用更抽象的术语来考虑端点会有所帮助.camel 文档 在这里没有多大帮助.端点可以被认为是组件的接口.每个组件可以配置 1 个或多个端点.它帮助我考虑路由上下文中的端点.一个简单的路由可以从端点 A(可以是 JMS 队列、tcp 套接字、文件或任何骆驼组件)到端点 B(可以是任何骆驼组件).当然,您也可以在路由中使用处理器来转换数据.

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.

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

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.

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

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.

这篇关于骆驼路线和端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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