0

Fabric8中,获得 ActiveMQ 连接的首选方式是通过mq-fabric配置文件,该配置文件通过声明式服务提供一个 ActitveMQConnection 对象。 GitHub 上给出了一个这样的例子,它工作得很好。

然而,我还没有找到一种方法让声明式服务和蓝图服务在 Fabric8(或任何 OSGI 环境,真的)中协作,因此,我的 OSGI 应用程序必须使用 DS 或蓝图。将两者混合似乎不是一种选择。

如果要使用蓝图(我这样做),则必须首先通过 Web UI 创建代理,然后返回控制台并键入cluster-list,找到 Fabric8 分配给代理的端口,然后在中配置连接像这样的蓝图:

<bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
  <property name="brokerURL" value="tcp://mydomain:33056" />
  <property name="userName" value="admin" />
  <property name="password" value="admin" />
</bean>

虽然这确实有效,但它并不完全适合部署,因为它涉及一些我希望尽可能避免的手动步骤。主要问题是我不知道那个端口会是什么。我已经梳理了配置文件,但在任何地方都找不到。

是否有一种更清洁、更自动化的方式来通过蓝图在 Fabric8 中获取 ActiveMQ 连接,还是我们必须使用声明式服务?

4

1 回答 1

0

在fabric-camel-demo中偶然发现了这个问题的解决方案,它说明了如何通过蓝图在 Fabric8 中实例化一个 ActiveMQConnectionFactory bean。

<!-- use the fabric protocol in the brokerURL to connect to the ActiveMQ broker registered as default name -->
<!-- notice we could have used amq as the component name in Camel, and avoid any configuration at all,
as the amq component is provided out of the box when running in fabric -->
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="discovery:(fabric:default)"/>
    <property name="userName" value="admin"/>
    <property name="password" value="admin"/>
</bean>

希望这可以帮助!

于 2014-06-11T14:31:48.350 回答