Remote access Wildfly hosted HornetQ from Spring (using MessageListenerContainer)

256 views Asked by At

My current setup calls for me to listen to a set of HornetQ queues hosted in Wildfly 8 from a standalone Spring application. My Spring application is able to connect to Wildfly's HornetQ and verify the JNDI queue names I have asked it to read; however, it never receives messages from the queue.

applicationContext.xml

<!-- Snippet -->
<!-- HornetQ JMS Connection Factory -->
<!-- Also tried HornetQConnectionFactory -->
<bean id="hornetQConnectionFactory" class="org.hornetq.jms.client.HornetQJMSConnectionFactory">
    <constructor-arg name="ha" value="false"/>
    <constructor-arg>
        <bean 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="use-nio" value="true"/>
                    <entry key="host" value="127.0.0.1"/>
                    <entry key="port" value="5455"/>            
                </map>
            </constructor-arg>      
        </bean>     
    </constructor-arg>
</bean>

<bean id="messageListenerAdapter" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
    <constructor-arg ref="springJmsConsumer"/>
    <property name="messageConverter">
        <bean class="com.demo.CustomMessageConverter"/>
    </property>
</bean>

<bean id="queueDestination" class="org.hornetq.jms.client.HornetQQueue">
    <constructor-arg value="demoQueue"/>
</bean>

<bean id="messageListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="hornetQConnectionFactory"/>
    <property name="messageListener" ref="messageListenerAdapter"/>
    <property name="destination" ref="queueDestination"/>
    <property name="cacheLevel" value="0"/>
</bean>

<!-- End Snippet -->

standalone-full.xml

    <!-- Relevant Snippets from standalone-full.xml -->
<subsystem xmlns="urn:jboss:domain:messaging:2.0">
    <hornetq-server>
        ...
        <connectors>
            ...
            <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
            </netty-connector>
        </connectors>

        <acceptors>
            ...
            <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
            </netty-acceptor>
        </acceptors>
        ...
        <jms-connection-factories>
            <connection-factory name="RemoteConnectionFactory">
                <connectors>
                    <connector-ref connector-name="netty-throughput"/>
                </connectors>
                <entries>
                    <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                </entries>
            </connection-factory>
            ...
        </jms-connection-factories>

        <jms-destinations>
            <jms-queue name="jms.queue.DemoQueue">
                <entry name="java:/jms/queue/DemoQueue"/>
                <entry name="java:/jboss/exported/jms/queue/DemoQueue">
            </jms-queue>
        </jms-destinations>
    </hornetq-server>
</subsystem>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
    <socket-binding name="messaging-throughput" port="5455"/>
    ...
</socket-binding-group>

Spring Server

public class SpringServer {
    ApplicationContext context = null;

    public void run() {
        context = new ClassPathXmlApplicationContext("applicationContext");
    }
}

Spring Consumer

@Service
public class SpringJmsConsumer implements MessageListener {
    @Override
    public void onMessage(Message message) {
        System.out.println("I received a message");
    }
}

Whenever I change the host, port, or queuename, I receive an error stating that the queue cannot be found. I'm confident I am connected to the HornetQ queue; however, Wildfly console does not describe any new connections when I start the Spring server, which I would expect it to give me some INFO text.

Any tips?

Thanks!

0

There are 0 answers