3

我有一个独立的 hornetq 服务器和一个使用它的JMS 客户端!关于 hornetq 用户手册,我应该只将jnp-client.jarjms.jar添加到客户端类路径中。但是当我尝试使用 hornetq 服务器(产生和消费消息)时,抛出了几个 ClassNotFoundExceptions,所以我强制将这些 jar 文件添加到我的客户端类路径中:

1. jms 2. jnp-client 3. hornetq-jms-client 4. netty 5. hornetq-core-cilent 6. jboss-common

我是在使用Hornetq 核心客户端而不是jms 客户端吗?jms客户端我真正需要什么jar文件?

我的 applicationContext.xml:

<!-- JndiTemplate -->
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
                <prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
                <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
            </props>
        </property>
</bean>

<!-- Connection Factory -->
<bean id="hornetqConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jndiTemplate"/>
        <property name="jndiName" value="/ConnectionFactory" />
</bean>

<!-- Destionation -->
<bean id="annotationDeleteCommandDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jndiTemplate"/>
        <property name="jndiName" value="/queue/command/annotation/deleteQueue" />
</bean>

<!-- Message Listener -->
<bean id="annotationMessageHandler" class="command.messaging.handler.annotation.AnnotationMessageHandler">
        <property name="annotationService" ref="annotationService"/>
</bean>

<!-- Message Listener Container -->
<bean id="annotationDeleteCommandMsgListenerContainer"
      class="org.springframework.jms.listener.DefaultMessageListenerContainer" 
      p:connectionFactory-ref="hornetqConnectionFactory"
      p:destination-ref="annotationDeleteCommandDestination"
      p:cacheLevelName="CACHE_CONSUMER"
      p:messageListener-ref="annotationDeleteCommandMessageHandler"
      p:concurrentConsumers="10"
      p:maxConcurrentConsumers="50"
      p:receiveTimeout="5000"
      p:idleTaskExecutionLimit="10
      p:idleConsumerLimit="5" />

<!-- Message Producer -->
<bean id="messageSender" class="command.messaging.sender.MessageSender">
        <property name="connectionFactory" ref="hornetqConnectionFactory" />
</bean>
4

2 回答 2

0

HornetQ-JMS-Client 是 HornetQ-Core-Client 的适配器,它公开了 JMS API。所以你需要他们两个。

而 HornetQ-Core-Client 在内部需要 netty,所以你也需要那个。

不确定jboss-common。你需要一些日志依赖,但我不记得到底是哪一个。

请注意,与 SOAP 不同,JMS 是一种 API,而不是协议。应用程序的其余部分独立于 API 提供者,但您需要正确的客户端库来理解您的 JMS 服务器使用的自定义协议。因此,例如,您不能使用 HornetQ JMS 客户端连接到 ActiveMQ。

于 2012-11-06T09:09:33.740 回答
0

根据文档...

如果您只使用纯 HornetQ Core 客户端(即没有 JMS),那么您需要 hornetq-core-client.jar、hornetq-commons.jar 和 netty.jar。

如果您在客户端使用 JMS,那么您还需要包含 hornetq-jms-client.jar 和 jboss-jms-api.jar。

这些是指独立 hornetq 下载的 lib 目录中的文件。

我也需要添加 jnp-client.jar 以避免 CNF。

于 2015-10-27T16:25:07.253 回答