1
votes

I have one Jboss EAP 6.3 instance with the HornetQ topic hosted there (jndi - "java:jboss/exported/jms/topic/TestTopic" so should be visible remotely) and I have another instanse (say Client) deployed to the same Jboss version. I have to listen to that TestTopic from the Client using @MessageDriven approach. I googled a lot but I still do not know how to specify a connection to the remote host to listen to that Topic. I found an example of using @ActivationConfigProperty(propertyName = "connectionParameters", propertyValue = "host=SOME_HOST;port=SOME_PORT"), but that property is not specified in the spec and seems to not have an influence.

Affairs so far: a part of 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>

and my bean settings

@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")})
3

3 Answers

1
votes

Eventually I solved the problem. Maybe will be helpful to someone: in fact no extra changes in standalone.xml needed. MDB just have to look like follows:

@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}")})

and here ${SOMETHING} is a system property defined in standalone.xml (to make this work a flag "annotation-property-replacement" in standalone.xml must be true):

<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>

Pay attention that user USERNAME must exist on the receiving server. If saying about Jboss it have to be application user added to guest group (this role has default permissions to send and receive messages)

Off course, setting properties is optional, I did it just to avoid hardcoding

0
votes

Check if you have to provide the @ResourceAdapter(value = "activemq-rar-5.6.0.rar") annotation on your MDB. I am looking at mine, I see all MDB's are annotated with this tag in addition tot he @MessageDriven.

Also standalone.xml should have the connection info to the server and port My standalone.xml has the activeMQ server url

0
votes

This fails in a clustered environment with JBoss EAP 6.4. For example, Foo.war is deployed twice in a cluster, then the second MDB will fail to register because of the duplicate client ID. If you make the Client ID unique, then both instances of the MDB will receive the message.

At this time, I do not have a work around.