Announcement Announcement Module
No announcement yet.
How do I connect to a remote HornetQ JMS server? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I connect to a remote HornetQ JMS server?

    Hello all,
    I would like to hookup Spring's DefaultMessageListenerContainer to a remote HornetQ instance. I am new to this, so I apologize if the answer is obvious.

    Does anyone have pointers to do this?

    I have it working with the embedded version:
    <!-- Embedded HornetQ container. -->
    <!-- appears to register beans named "/queue/*" based on whatever queues I defined in my config. -->
    <bean id="EmbeddedJms" class="org.hornetq.integration.spring.SpringJmsBootstrap" init-method="start" destroy-method="stop" />
    <!-- My listener class...just the example provided by Bill Burke in the HornetQ examples.  implements javax.jms.MessageListener -->
    <bean id="listener" class="mydomain.ExampleListener" />
    <!-- Simple great. -->
    <bean id="MessageSender" class="mydomain.MessageSender">
    	<property name="connectionFactory" ref="ConnectionFactory" />
    	<property name="destination" ref="/queue/foo" />
    <!-- The part I am trying to get wired! -->
    <bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    	<property name="connectionFactory" ref="ConnectionFactory" />
    	<property name="destination" ref="/queue/foo" />
    	<property name="messageListener" ref="listener" />
    How can I get this same code running against a server on

    Is there a portable way to connect org.springframework.jms.listener.DefaultMessageLis tenerContainer to a remote JMS server?

    How would I do this if I am running HornetQ as a standalone app?

    How would I do that to connect to JBoss AS 6 or 7?

    I was hoping to demo this code from JUnit/TestNG and not have to deploy it to a container.


  • #2
    Here's a sample that I use to connect to a remote WebLogic JMS Server. You'll simply need to change the naming factory I suppose.
    The jms:message-driven-channel-adapter is a jms listener and has the same config attributes as any other listener.

        <int-jms:message-driven-channel-adapter id="xmlInputJms" channel="ordersMessage"
                                                pub-sub-domain="false" connection-factory="connectionFactory"
                                                transaction-manager="transactionManager" acknowledge="client"
        <bean id="destinationResolver" class="">
            <property name="jndiTemplate" ref="jndiTemplate"/>
        <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
            <property name="environment">
                    <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
                    <prop key="java.naming.provider.url">t3://localhost:7001/</prop>
        <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiTemplate" ref="jndiTemplate"/>
            <property name="jndiName" value=""/>
        <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>