在Fabric8中使用Blueprint而不是DS的ActiveMQ连接

在Fabric8中使用Blueprint而不是DS的ActiveMQ连接,activemq,blueprint-osgi,fabric8,Activemq,Blueprint Osgi,Fabric8,在Fabric8中,获取ActiveMQ连接的首选方法是通过,它通过声明性服务提供ActivtVemQConnection对象,这很好用 然而,我还没有找到一种方法让声明性服务和Blueprint服务在Fabric8或任何OSGI环境中协作,因此,我的OSGI应用程序必须使用DS或Blueprint。两者混合似乎不是一种选择 如果您想使用blueprint,您必须首先通过web UI创建一个代理,然后返回控制台并键入集群列表,找到Fabric8分配给代理的端口,然后在blueprint中配置连接

在Fabric8中,获取ActiveMQ连接的首选方法是通过,它通过声明性服务提供ActivtVemQConnection对象,这很好用

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

如果您想使用blueprint,您必须首先通过web UI创建一个代理,然后返回控制台并键入集群列表,找到Fabric8分配给代理的端口,然后在blueprint中配置连接,如下所示:

<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>
虽然这确实有效,但它并不完全适合部署,因为它涉及一些手动步骤,如果可能的话,我希望避免这些步骤。主要的问题是,我不知道那个端口将是什么。我仔细检查了配置文件,在任何地方都找不到


是否有更干净、更自动化的方法通过blueprint在Fabric8中获得ActiveMQ连接,或者我们必须使用声明性服务?

在中偶然发现了解决此问题的解决方案,该解决方案演示了如何通过blueprint在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>
希望这有帮助