【问题标题】:Accessing OpenMQ JMS Broker from ServiceMix+Camel从 ServiceMix+Camel 访问 OpenMQ JMS Broker
【发布时间】:2014-09-23 02:15:58
【问题描述】:

我正在尝试让 ServiceMix+Camel 与 OpenMQ JMS 代理交谈。我在 Blueprint DSL 中定义了一个 Camel 路由定义,它将消息发布到 ActiveMQ JMS 队列中。这工作正常,但我现在正尝试将其转换为将消息发布到在 Glassfish4 容器内运行的 OpenMQ 实例。

我正在运行以下配置: JDK 1.7.0_60 ServiceMix 5.1.1(所以 Camel 2.13.2)

关于这个主题的文档有点少,但我从 Google 搜索 herehere 中收集了各种 sn-ps,并提出了以下内容(仅相关部分):

....
  <!-- Post over JMS into Manager -->
  <to uri="openmq:queue:resman"/>
 </route>
</camelContext> 

<bean id="openmq" class="org.apache.camel.component.jms.JmsComponent">
 <property name="connectionFactory">
  <bean class="com.sun.messaging.ConnectionFactory">
   <property name="imqAddressList" value="localhost:7676"/>
  </bean>
 </property>
</bean>

我在 Servicemix/OSGI 中启用了以下与 JMS 相关的“功能”:

[installed  ] [3.2.4.RELEASE  ] spring-jms
[installed  ] [2.13.2         ] camel-jms

我安装并激活了以下 OSGI 包:

[  89] [Active     ] [            ] [       ] [   50] geronimo-jms_1.1_spec (1.1.1)
[ 126] [Active     ] [            ] [       ] [   50] camel-jms (2.13.2)

在我将 Came Route 蓝图部署到 ServiceMix 时,我遇到的问题是 ClassNotFoundException。以下是 Stacktrace 记录的相关 sn-ps:

org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to instantiate components
Caused by: java.lang.NoClassDefFoundError: javax/jms/JMSContext
Caused by: java.lang.ClassNotFoundException: javax.jms.JMSContext not found by org.apache.geronimo.specs.geronimo-jms_1.1_spec [89]

所以假设这是一个 OSGI 捆绑问题,我已经深入研究了 Camel 的“功能”,只是为了确认依赖关系:

karaf@root> features:info camel-jms
Description of camel-jms 2.13.2 feature
----------------------------------------------------------------
Feature has no configuration
Feature has no configuration files
Feature depends on:
  spring [3.2,4)
  spring-jms [3.2,4)
  camel-core 2.13.2
Feature contains followed bundles:
  mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1 start-level=50
  mvn:commons-pool/commons-pool/1.6 start-level=50
  mvn:org.apache.geronimo.specs/geronimo-jms_1.1_spec/1.1.1 start-level=50
  mvn:org.apache.camel/camel-jms/2.13.2 start-level=50

看来是“geronimo-jms_1.1_spec”导致堆栈跟踪,因为它找不到 JMSContext。我做了一个很大的假设,因为 ApacheMQ 必须使用相同的 JMS 类,所以它必须在某个环境中。此外,JMSContext 似乎是一个 JMS 2.0 API 接口,那么这里的问题是 geronimo-jms_1.1_spec 包试图引用 JMS2 API 吗?

我还遇到了将 OpenMQ 的客户端 JAR 安装到环境中的问题。 Glassfish4 附带的 OpenMQ 客户端 JAR 是普通 JAR,而不是 OSGI 包(请参阅https://java.net/jira/browse/MQ-328),因此我计划使用“file:wrap”功能将其部署到 ServiceMix,或者解压并重新打包到 JAR包含我的 Beans。我不认为这与这个问题有关,但我可能是错的。

【问题讨论】:

    标签: apache-camel jms glassfish-4 apache-servicemix openmq


    【解决方案1】:

    好的,终于解决了这个问题。线索在于对 javax.jms.JMSContext 的引用,这是 JMS 2.0 API 中的新内容。我试图使用从 Glassfish4 发行版中获取的 OpenMQ 客户端库(imq.jar 和 jms.jar),该发行版位于 JEE7 和 JMS v1.1 中。 ServiceMix 5.1.1 仍处于 JMS V1.1,因此出现 ClassNotFoundException。

    解决方案: 当连接到在 Glassfish4 下运行的 OpenMQ 实例时,您需要下载并使用先前 Glassfish 3.2.2 版本中的 OpenMQ 客户端库。您可以从 Glassfish 项目档案here 获取此发行版。

    到目前为止的测试表明它运行良好,所以如果我发现任何相关的东西,我会回来更新这篇文章。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-04
      • 2021-05-15
      • 2017-05-26
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      • 2011-07-06
      • 2014-10-02
      相关资源
      最近更新 更多