我在使用JBoss 5.1.2运行的MDB时遇到问题,通过JMS连接到远程独立的HornetQ。我知道HornetQ正常运行,因为我可以连接到它并通过HermesJMS发送/查看消息。但是,我的实际应用程序似乎无法成功连接到它。
这是我的@MessageDriven注释:
@MessageDriven(
messageListenerInterface = MessageListener.class,
activationConfig = {
@ActivationConfigProperty( //type of destination we pull messages from
propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty( //which destination JNDI suffix we pull message from
propertyName = "destination", propertyValue = "queue/inputQueue"),
@ActivationConfigProperty( //how many times to reattempt on service errors
propertyName = "dLQMaxResent", propertyValue = "1"),
@ActivationConfigProperty( //how many seconds to try a reconnect when failure to connect to jms provider
propertyName = "reconnectInterval", propertyValue = "15"),
@ActivationConfigProperty(
propertyName = "providerAdapterJNDI", propertyValue = "java:/RemoteJMSProvider")
}
)
这是我在jms-ds.xml文件中的配置:
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
name="hornetq:service=MSProviderLoader,name=RemoteJMSProvider,server=remotehost">
<attribute name="ProviderName">RemoteJMSProvider</attribute>
<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
<!-- The connection factory -->
<attribute name="FactoryRef">/LocalHornetQConnectionFactory</attribute>
<!-- The queue connection factory -->
<attribute name="QueueFactoryRef">/LocalHornetQConnectionFactory</attribute>
<!-- The topic factory -->
<attribute name="TopicFactoryRef">/LocalHornetQConnectionFactory</attribute>
<!-- Connect to JNDI on the host "the-remote-host-name" port 1099-->
<attribute name="Properties">
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=IPADDRESS:1099
</attribute> </mbean>
我可以在JBoss jmx-console中查看RemoteJMSProvider。另外,在JNDIView中,我可以看到远程JMS提供程序的JNDI名称。我也可以在JMX控制台中看到jms.queue.inputQueue,但是当我尝试查看它上面的消息时,它表示没有,即使我知道有查看HermesJMS。
最后,我的申请中没有例外。这一切似乎运行正常,但它从未收到任何消息。即使HornetQ日志显示我的IP地址已连接,所以我不确定为什么我不能读取队列:
[RMI TCP Connection(6)-10.3.78.123] 17:02:06,837 FINER [sun.rmi.transport.tcp] RMI TCP Connection(6)-10.3.78.123: (port 1098) client using 10.3.78.123:0
有什么想法吗?
这是我的HornetQ(2.2.5)配置信息供参考。
将hornetq-jms.xml文件:
<connection-factory name="LocalHornetQConnectionFactory">
<xa>true</xa>
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="/LocalHornetQConnectionFactory"/>
</entries>
<retry-interval>5000</retry-interval>
<retry-interval-multiplier>1.0</retry-interval-multiplier>
<reconnect-attempts>-1</reconnect-attempts>
<failover-on-server-shutdown>true</failover-on-server-shutdown>
<confirmation-window-size>1048576</confirmation-window-size>
</connection-factory>
<queue name="invalidQueue">
<entry name="/queue/invalidQueue"/>
</queue>
<queue name="inputQueue">
<entry name="/queue/inputQueue"/>
</queue>
<queue name="errorQueue">
<entry name="/queue/errorQueue"/>
</queue>
<topic name="SAFEStorageAcknowledgement">
<entry name="/topic/SAFEStorageAcknowledgement"/>
</topic>
<topic name="SAFEEvents">
<entry name="/topic/SAFEEvents"/>
</topic>
hornetq-configuration.xml文件:
<address-settings>
<!--default for catch all-->
<address-setting match="#">
<dead-letter-address>jms.queue.errorQueue</dead-letter-address>
<expiry-address>jms.queue.errorQueue</expiry-address>
<redelivery-delay>15000</redelivery-delay>
<max-size-bytes>10485760</max-size-bytes>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
<address-full-policy>BLOCK</address-full-policy>
<redistribution-delay>60000</redistribution-delay>
</address-setting>
</address-settings>
<queues>
<queue name="jms.queue.inputQueue">
<address>jms.queue.inputQueue</address>
</queue>
<queue name="jms.queue.errorQueue">
<address>jms.queue.errorQueue</address>
</queue>
<queue name="jms.queue.invalidQueue">
<address>jms.queue.invalidQueue</address>
</queue>
</queues>
所有其他HornetQ设置都是默认设置。
谢谢, 安迪
答案 0 :(得分:0)
您必须在ra.xml上或作为注释指定两个激活属性:
ConnectorClassName = org.hornetq.core.remoting.impl.netty.NettyConnectorFactory
ConnectionParameters = host = 127.0.0.1; port = 5446
在HornetQ发行版中,有一个名为javaee / jca-remote的示例,它使用ra.xml配置激活属性。