Apache camel 将OSGi服务公开为Camel端点
我甚至不知道我是否正确地表述了这个问题;-) 我基本上想要实现的是这样的:Apache camel 将OSGi服务公开为Camel端点,apache-camel,osgi,blueprint-osgi,Apache Camel,Osgi,Blueprint Osgi,我甚至不知道我是否正确地表述了这个问题;-) 我基本上想要实现的是这样的: <route > <from uri="osgi:serviceName"/> <!-- do some processing -> <to uri="activemq:queue:inbox"/> </route> 只需在camel之外创建一个OSGi服务和一个以direct:anyname开头的路由。然后,您可以将一个Produc
<route >
<from uri="osgi:serviceName"/>
<!-- do some processing ->
<to uri="activemq:queue:inbox"/>
</route>
只需在camel之外创建一个OSGi服务和一个以direct:anyname开头的路由。然后,您可以将一个ProducerTemplate注入到您的服务中,并从那里调用路由。要在Camel路由中使用“osgi”作为URI方案,您需要创建一个自定义Camel组件来处理调用相关osgi命令。有关更多信息,请参阅
一个更简单的替代方法是编写自定义OSGi命令,使用ProducerTemplate将消息发送到驼峰路由。卡拉夫的一个例子可以在这里找到:
注入ProducerTemplate可以通过标准的Spring配置来完成。如果您有非常简单的方法签名,或者想要传递的参数的typeConverter,您可以使用它在一个简单的XML配置文件中将服务链接到您的路由
要扩展文档的示例,您可以使用以下内容:
<osgi:service id="service" ref="myProxySender" (4)
interface="org.apache.camel.spring.config.MyProxySender" />
<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- create a proxy that will route to the direct:start endpoint when invoked -->
<proxy id="myProxySender"
serviceInterface="org.apache.camel.spring.config.MyProxySender"
serviceUrl="direct:start"/>
<!-- this is the route that our proxy will routed when invoked
and the output from this route is returned as reply on the proxy -->
<route>
<from uri="direct:start"/>
<transform>
<simple>Bye ${body}</simple>
</transform>
</route>
</camelContext>
再见${body}
您能更详细地解释一下“向您的服务中注入产品模板”吗?或者你有没有举个例子?干杯我认为最简单的方法是注入CamelContext并执行ProducerTemplate producer=context.createProducerTemplate();