2015-05-18 58 views
1

我有一个Jboss EAP 6.3实例,其中包含HornetQ主题(jndi - “java:jboss/exported/jms/topic/TestTopic”,因此应该可以远程查看)我还有另一个实例(比如客户端)部署到相同的Jboss版本。我必须使用@MessageDriven方法从客户端听该TestTopic。我GOOGLE了很多,但我仍然不知道如何指定连接到远程主机来听该主题。我发现了一个使用@ActivationConfigProperty(propertyName =“connectionParameters”,propertyValue =“host = SOME_HOST; port = SOME_PORT”)的示例,但该属性未在规范中指定,似乎没有影响。Jboss EAP 6.3 - 收听远程JMS主题(HornetQ)

事务迄今: standalone.xml的一部分:

<subsystem xmlns="urn:jboss:domain:messaging:1.4"> 
     <hornetq-server> 
      <persistence-enabled>true</persistence-enabled> 
      <journal-type>NIO</journal-type> 
      <journal-min-files>2</journal-min-files> 

      <connectors> 
       <netty-connector name="netty" socket-binding="messaging"/> 
       <netty-connector name="netty-throughput" socket-binding="messaging-throughput"> 
        <param key="batch-delay" value="50"/> 
       </netty-connector> 
       <in-vm-connector name="in-vm" server-id="0"/> 
      </connectors> 

      <acceptors> 
       <netty-acceptor name="netty" socket-binding="messaging"/> 
       <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput"> 
        <param key="batch-delay" value="50"/> 
        <param key="direct-deliver" value="false"/> 
       </netty-acceptor> 
       <in-vm-acceptor name="in-vm" server-id="0"/> 
      </acceptors> 

      <security-settings> 
       <security-setting match="#"> 
        <permission type="send" roles="guest"/> 
        <permission type="consume" roles="guest"/> 
        <permission type="createNonDurableQueue" roles="guest"/> 
        <permission type="deleteNonDurableQueue" roles="guest"/> 
       </security-setting> 
      </security-settings> 

      <address-settings> 
       <address-setting match="#"> 
        <dead-letter-address>jms.queue.DLQ</dead-letter-address> 
        <expiry-address>jms.queue.ExpiryQueue</expiry-address> 
        <redelivery-delay>0</redelivery-delay> 
        <max-size-bytes>10485760</max-size-bytes> 
        <page-size-bytes>2097152</page-size-bytes> 
        <address-full-policy>PAGE</address-full-policy> 
        <message-counter-history-day-limit>10</message-counter-history-day-limit> 
       </address-setting> 
      </address-settings> 

      <jms-connection-factories> 
       <connection-factory name="InVmConnectionFactory"> 
        <connectors> 
         <connector-ref connector-name="in-vm"/> 
        </connectors> 
        <entries> 
         <entry name="java:/ConnectionFactory"/> 
        </entries> 
       </connection-factory> 
       <connection-factory name="RemoteConnectionFactory"> 
        <connectors> 
         <connector-ref connector-name="netty"/> 
        </connectors> 
        <entries> 
         <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/> 
        </entries> 
       </connection-factory> 
       <pooled-connection-factory name="hornetq-ra"> 
        <transaction mode="xa"/> 
        <connectors> 
         <connector-ref connector-name="in-vm"/> 
        </connectors> 
        <entries> 
         <entry name="java:/JmsXA"/> 
        </entries> 
       </pooled-connection-factory> 
      </jms-connection-factories> 

      <jms-destinations> 
       <jms-queue name="ExpiryQueue"> 
        <entry name="java:/jms/queue/ExpiryQueue"/> 
       </jms-queue> 
       <jms-queue name="DLQ"> 
        <entry name="java:/jms/queue/DLQ"/> 
       </jms-queue> 
       <jms-topic name="TestTopic"> 
        <entry name="java:/jms/topic/TestTopic"/> 
        <entry name="java:jboss/exported/jms/topic/TestTopic"/> 
       </jms-topic> 
      </jms-destinations> 
     </hornetq-server> 
    </subsystem> 

和我的豆设置

@MessageDriven(mappedName = "TestTopicRemote", activationConfig = { 
    @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), 
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), 
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/exported/jms/topic/TestTopic"), 
    @ActivationConfigProperty(propertyName = "connectionFactoryLookup", propertyValue = "jms/RemoteConnectionFactory"), 
    @ActivationConfigProperty(propertyName = "clientId", propertyValue = "guest"), 
    @ActivationConfigProperty(propertyName = "connectionParameters", propertyValue = "host=MY_HOST;port=5445")}) 

回答

0

检查是否已提供@ResourceAdapter(值=“的ActiveMQ-RAR -5.6.0.rar“)注释在您的MDB上。我在看我的,我看到所有MDB的注释都是用这个标签加上@MessageDriven。

而且standalone.xml应具备的连接信息到服务器,端口 我standalone.xml拥有的ActiveMQ服务器的URL

+0

你使用的是什么版本的jboss?我看到像“activemq-rar-5.6.0.rar”这样的东西只用于旧版本。 –

+0

您还可以提供从您的standalone.xml中指定服务器和端口的内容吗? –

1

我终于解决了这个问题。也许会对某人有所帮助:实际上,在standalone.xml中不需要额外的更改。 MDB只是看起来像如下:

@MessageDriven(mappedName = "TestTopicRemote", activationConfig = { 
    @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), 
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"), 
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "TestTopic"), 
    @ActivationConfigProperty(propertyName = "connectorClassName", propertyValue = "${jms.topic.connectorClassName}"), 
    @ActivationConfigProperty(propertyName = "user", propertyValue = "${jms.topic.user}"), 
    @ActivationConfigProperty(propertyName = "password", propertyValue = "${jms.topic.password}"), 
    @ActivationConfigProperty(propertyName = "connectionParameters", propertyValue = "${jms.topic.connectionParameters}")}) 

这里${SOMETHING}是standalone.xml定义的系统属性(以使standalone.xml这项工作标志“注释属性替换”必须是真实的):

<system-properties> 
    <property name="jms.topic.connectorClassName" value="org.hornetq.core.remoting.impl.netty.NettyConnectorFactory"/> 
    <property name="jms.o.user" value="USERNAME"/> 
    <property name="jms.o.password" value="PASSWORD"/> 
    <property name="jms.o.connectionParameters" value="host=YOUR_HOST;port=5445"/> 
</system-properties> 

请注意,用户USERNAME必须存在于接收服务器上。如果说有关的Jboss它必须是应用程序用户添加到来宾组(该角色具有默认权限发送和接收消息)

关当然,设置属性是可选的,我这样做只是为了避免硬编码

+0

las HornetQ不会连接使用jnp:// localhost/1099,NamingContextFactory,属性来获取连接工厂? – fatherazrael

0

这在JBoss EAP 6.4集群环境中失败。例如,Foo.war在群集中部署两次,然后由于重复的客户端ID,第二个MDB将无法注册。如果您使客户端ID唯一,那么MDB的两个实例都将收到该消息。

在这个时候,我没有工作。