HornetQ: Consuming messages from a remote JMS Topic
robertjlee Oct 7, 2009 11:27 AMWe have the following bridge, which pulls messages from a remote topic correctly, but does not then place them into a local queue - the messages simply disappear. At first we thought this was because there was no subscriber on the queue, but having added an MDB to log each message, it didn't pick up. Is this a bug or are we doing something wrong?
We have also had no luck trying to get the MDBean to connect directly to the topic (which we'd rather not do anyway since the connection may be unreliable so we'd like to guarantee that as messages are pulled across as quickly as possible and cached in a queue before processing).
The topic resides on a machine named "pinnet" and both servers are using HornetQ 2.0Beta5 under JBoss 5.
Aside: We are trying to evaluate HornetQ as a possible replacement for JBoss MQ for use in a messaging system over the Internet (we have had significant problems with JBoss Messaging 1.x through firewalls). All the examples, including the JMS Bridge, seem to be moving messages between local queues. Is there any chance of a more useful example? (I'm not sure why you'd ever want to use a JMS Bridge on a local machine). It makes developing more complex situations quite hard.
jms-bridge-jboss-beans.xml:
<?xml version="1.0" encoding="UTF-8"?> <deployment xmlns="urn:jboss:bean-deployer:2.0"> <bean name="PinnacleProIncomingDataHighPriorityQueueBridge" class="org.hornetq.jms.bridge.impl.JMSBridgeImpl"> <!-- HornetQ must be started before the bridge --> <depends>HornetQServer</depends> <constructor> <!-- Source ConnectionFactory Factory --> <parameter> <inject bean="SourceCFF"/> </parameter> <!-- Target ConnectionFactory Factory --> <parameter> <inject bean="TargetCFF"/> </parameter> <!-- Source DestinationFactory --> <parameter> <inject bean="SourceDestinationFactory"/> </parameter> <!-- Target DestinationFactory --> <parameter> <inject bean="TargetDestinationFactory"/> </parameter> <!-- Source User Name (no username here) --> <parameter><null /></parameter> <!-- Source Password (no password here)--> <parameter><null /></parameter> <!-- Target User Name (no username here)--> <parameter><null /></parameter> <!-- Target Password (no password here)--> <parameter><null /></parameter> <!-- Selector --> <parameter>messagedestination is null or messagedestination='ALL' or messagedestination like '%,team3,%'</parameter> <!-- Failure Retry Interval (in ms) --> <parameter>5000</parameter> <!-- Max Retries --> <parameter>10</parameter> <!-- Quality Of Service --> <parameter>DUPLICATES_OK</parameter> <!-- Max Batch Size --> <parameter>500</parameter> <!-- Max Batch Time (-1 means infinite) --> <parameter>30000</parameter> <!-- Subscription name (no subscription name here)--> <parameter>PinnacleNetTopicProcessor</parameter> <!-- Client ID (no client ID here)--> <parameter>team3TopicClient</parameter> <!-- Add MessageID In Header --> <parameter>false</parameter> </constructor> <property name="transactionManager"> <inject bean="RealTransactionManager"/> </property> </bean> <!-- SourceCFF describes the ConnectionFactory used to connect to the source destination --> <bean name="SourceCFF" class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory"> <constructor> <parameter> <inject bean="LocalJNDI" /> </parameter> <parameter>/ConnectionFactory</parameter> </constructor> </bean> <!-- TargetCFF describes the ConnectionFactory used to connect to the target destination --> <bean name="TargetCFF" class="org.hornetq.jms.bridge.impl.JNDIConnectionFactoryFactory"> <constructor> <parameter> <inject bean="LocalJNDI" /> </parameter> <parameter>/ConnectionFactory</parameter> </constructor> </bean> <!-- SourceDestinationFactory describes the Destination used as the source --> <bean name="SourceDestinationFactory" class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory"> <constructor> <parameter> <inject bean="RemoteJNDI" /> </parameter> <parameter>/topic/PinnacleNetTopic</parameter> </constructor> </bean> <!-- TargetDestinationFactory describes the Destination used as the target --> <bean name="TargetDestinationFactory" class="org.hornetq.jms.bridge.impl.JNDIDestinationFactory"> <constructor> <parameter> <inject bean="LocalJNDI" /> </parameter> <parameter>/queue/PinnacleNetIncomingDataHighPriorityQueue</parameter> </constructor> </bean> <!-- JNDI is a Hashtable containing the JNDI properties required --> <!-- to connect to the sources and targets JMS resrouces --> <bean name="LocalJNDI" class="java.util.Hashtable"> <constructor class="java.util.Map"> <map class="java.util.Hashtable" keyClass="java.lang.String" valueClass="java.lang.String"> <entry> <key>java.naming.factory.initial</key> <value>org.jnp.interfaces.NamingContextFactory</value> </entry> <entry> <key>java.naming.provider.url</key> <value>jnp://localhost:1099</value> </entry> <entry> <key>java.naming.factory.url.pkgs</key> <value>org.jboss.naming:org.jnp.interfaces"</value> </entry> </map> </constructor> </bean> <!-- JNDI is a Hashtable containing the JNDI properties required --> <!-- to connect to the sources and targets JMS resrouces --> <bean name="RemoteJNDI" class="java.util.Hashtable"> <constructor class="java.util.Map"> <map class="java.util.Hashtable" keyClass="java.lang.String" valueClass="java.lang.String"> <entry> <key>java.naming.factory.initial</key> <value>org.jnp.interfaces.NamingContextFactory</value> </entry> <entry> <key>java.naming.provider.url</key> <value>jnp://pinnet:1099</value> </entry> <entry> <key>java.naming.factory.url.pkgs</key> <value>org.jboss.naming:org.jnp.interfaces"</value> </entry> </map> </constructor> </bean> </deployment>