【问题标题】:ActiveMQ connection in Fabric8 using Blueprint instead of DSFabric8 中的 ActiveMQ 连接使用蓝图而不是 DS
【发布时间】:2014-06-10 17:47:47
【问题描述】:

Fabric8 中,获得 ActiveMQ 连接的首选方式是通过 mq-fabric profile,它通过声明式服务提供一个 ActitveMQConnection 对象。 An example of this is given on 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 连接,还是我们必须使用声明式服务?

【问题讨论】:

    标签: activemq blueprint-osgi fabric8


    【解决方案1】:

    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>
    

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2013-06-25
      • 2015-06-11
      • 2016-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-20
      • 2015-10-12
      • 2020-11-26
      相关资源
      最近更新 更多