0
votes

Is it possible (if yes, with what configuration?) to have a Spring application running on one JBoss instance connect to a JMS queue defined on a different JBoss instance? I read a few pages about how to do it programmatically, but is it possible to have the queue injected in the Spring app so the application is not aware of the remote location of the queue and not required to do an explicit lookup?

Ideally, to have the JNDI name of the queue being resolved to a remote queue by the "client JBoss". An acceptable option would be to have the client application define the queue as remote in the <jms:listener> configuration.

Software: JBoss EAP 6.2, Spring 3.x

1

1 Answers

0
votes

Yes you can use remoting NettyConnectionFactory

<bean name="liveTransportConfiguration" class="org.hornetq.api.core.TransportConfiguration">
        <constructor-arg value="org.hornetq.core.remoting.impl.netty.NettyConnectorFactory" />
        <constructor-arg>
            <map key-type="java.lang.String" value-type="java.lang.Object">
                <entry key="port" value="5445"></entry>
                <entry key="host" value="ip of server"></entry>
            </map>
        </constructor-arg>
</bean>





<bean name="connectionFactory" class="com.kp.KPHornetQJMSConnectionFactory"
        destroy-method="close">
        <constructor-arg name="ha" type="boolean" value="false" />
        <constructor-arg>
            <array>
                <ref bean="liveTransportConfiguration"></ref>
            </array>
        </constructor-arg>

        <property name="clientFailureCheckPeriod" value="5000" />
        <property name="retryInterval" value="1000" />
        <property name="retryIntervalMultiplier" value="1.0" />
        <property name="reconnectAttempts" value="-1" />
        <property name="confirmationWindowSize" value="-1" />   
</bean>

<bean name="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="connectionFactory"></property>
</bean>


<bean name="kpListener" class="Your jms MessageListener">
        <property name="jmsTemplate" ref="jmsTemplate"></property>
</bean>

<jms:listener-container connection-factory="connectionFactory" concurrency="1">
        <jms:listener destination="myqueue" ref="kpListener" method="onMessage" />
</jms:listener-container>

KPHornetQJMSConnectionFactory.java class

public class KPHornetQJMSConnectionFactory extends HornetQJMSConnectionFactory {

    private static final long serialVersionUID = -712113311282964108L;

    public KPHornetQJMSConnectionFactory(final boolean ha,
            org.hornetq.api.core.TransportConfiguration transportConfiguration) {
        super(ha, transportConfiguration);
        super.setUseGlobalPools(false);
    }   

}