骆驼OSGi容器:适用InterceptStrategy所有的骆驼上下文 [英] Camel in OSGi Container: Apply InterceptStrategy to all camel contexts

查看:200
本文介绍了骆驼OSGi容器:适用InterceptStrategy所有的骆驼上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须部署到OSGi容器几束(A,B和C),每包含 CamelContext 和部分航线。我还有一个包(M)以 CamelContext 与路由(收集监测数据)和 InterceptStrategy 豆。我想从M中的 InterceptStrategy 豆在容器自动适用于所有的其它 CamelContext S(即那些A,B和C),而无需修改其他包。

最终,目标是从每个 CamelContext 窃听数据到M中的路线,而不必进行到A,B或C的任何变化来明确路由兑换。这是方法或类似的方法可行?

所有 CamelContext 的S使用Spring XML配置。


更新:其他上下文

捆绑A,B和C含有负责处理数据的核心产品。捆绑M含有一个可选的监测工具,专门用来测量流经A,B和C目前数据的某些参数,添加选用的工具需要改变A,B和C的路由添加额外的处理器 s到充实兑换通过监测数据和监测数据之前读<到/方式> 终端

我们的目标是能够在捆绑M键拖放到与A,B和C一个已经证实,作为工作的制度;并使其自动应用到现有的路由,而不必修改配置为现有和 - 工作包。它的的接受进行修改,以A,B和C,以支持这一点,只要改变不会引起A,B和C依靠M上运行(即ABC仍然必须无米长跑)。

如果有更好的方法来做到这一点比使用拦截器,我持开放的态度。的主要目标是:


  1. 保持A,B和C的M脱钩(特别是在开发中)

  2. 确保与A,B整合M和C尽可能
  3. 一样简单
  4. 允许将无需手动更改A,B或C集成中号


解决方案

我不认为这是可能使用 InterceptorStrategy 因为这预计是在同一个骆驼上下文中运行。唯一的办法我知道跨多个环境中工作使用VM端点(这显然是仅限于同一个JVM)的,但是在这种情况下,你很可能会使用JMS,JMX或类似的东西。好

JMS

创建一个 InterceptorStrategy 在每个骆驼背景 A,B和; ç一个发布你的信息到 M

 拦截()豆(transformForMonitoring)。要(JMS:队列:监控)。从(凡是:端点)
    .process(myProcessor)
    。要(目标:端点);

您也可以使用 VM 拦截组件()如果你不想JMS的开销,然而,这限制了你的监控组件单个JVM。

JMX

这是一个有点复杂,但其基本思想是告诉骆驼的上下文来发布MBean的 A,B和; ç

 < camelContext ID =骆驼的xmlns =htt​​p://camel.apache.org/schema/spring>
  < jmxAgent ID =代理人mbeanObjectDomainName =your.domain.name/>
    ...
< / camelContext>

再有 M 连接到JVM MBean服务器,并利用像<一个href=\"http://camel.apache.org/camel-jmx.html#CamelJMX-HowtousetheJMXNotificationListenertolistenthecamelevents\"相对=nofollow>的NotificationListener 反应的交流。

I have several bundles (A, B, and C) deployed to an OSGi container, each containing a CamelContext and some routes. I have another bundle (M) with a CamelContext with a route (for collecting monitoring data) and a InterceptStrategy bean. I would like the InterceptStrategy bean from M to automatically apply to all of the other CamelContexts in the container (i.e., those in A, B, and C), without having to modify the other bundles.

Ultimately, the goal is to wiretap data from each CamelContext into the route in M, without having to make any changes to A, B, or C to explicitly route the Exchange. Is this approach or a similar approach doable?

All of the CamelContexts are configured using Spring XML.


Update: Additional Context

Bundles A, B, and C contain the core product responsible for processing data. Bundle M contains an optional monitoring tool, designed to measure certain parameters of the data flowing through A, B, and C. Currently, adding on the optional tool requires changing the routes in A, B, and C to add additional Processors to enrich the Exchange with the monitoring data and to read the monitoring data prior to <to /> endpoints.

The goal is to be able to drop in Bundle M into a already verified-as-working system with A, B, and C; and have it automatically apply to the existing routes without having to modify the configuration for the existing-and-working bundles. It is acceptable to make modifications to A, B, and C to support this, as long as the changes do not cause A, B, and C to rely on M to run (i.e., ABC must still run without M).

If there is a better means to do this than using interceptors, I am open to that. The primary goals are:

  1. Keep A, B, and C decoupled from M (particularly during development)
  2. Ensure integrating M with A, B, and C is as easy as possible
  3. Allow M to be integrated without having to manually change A, B, or C

解决方案

I dont think this is possible using InterceptorStrategy since that expects it is running in the same camel context. The only ways I am aware of working across multiple contexts is using the VM endpoint (which is obviously limited to the same JVM), however in this case you would probably be better utilising JMS, JMX or something similar.

JMS

Create an InterceptorStrategy for each camel context in A, B & C that publishes your messages to M

intercept().bean(transformForMonitoring).to("jms:queue:monitoring");

from("whatever:endpoint")
    .process(myProcessor)
    .to("target:endpoint");

You could also use the vm component on the intercept() if you dont want the overhead of JMS, however this limits your monitoring component to a single JVM.

JMX

This is a bit more complicated, but the basic idea is to tell the camel context to publish MBeans for A, B & C

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
  <jmxAgent id="agent" mbeanObjectDomainName="your.domain.name"/>
    ...
</camelContext>

and then have M connect to the JVM MBean Server and utilise something like NotificationListener to react to the Exchanges.

这篇关于骆驼OSGi容器:适用InterceptStrategy所有的骆驼上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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