Announcement Announcement Module
Collapse
No announcement yet.
How do I connect to a remote HornetQ JMS server? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:
    Code:
    <!-- 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 client...works great. -->
    <bean id="MessageSender" class="mydomain.MessageSender">
    	<property name="connectionFactory" ref="ConnectionFactory" />
    	<property name="destination" ref="/queue/foo" />
    </bean>
    
    <!-- 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" />
    </bean>
    How can I get this same code running against a server on 192.168.1.100?

    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.

    Thanks!
    Steven

  • #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.

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

    Comment

    Working...
    X