You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by javatestcase <ja...@yahoo.com> on 2012/11/26 21:41:25 UTC

JMS Bridge - trying to copy all messages to remote server

Been trying to get ActiveMQ 5.7.0 running on JBossAS 5.1.0 set up to use a
JMS to JMS bridge to copy every message from a queue on the local broker to
a remote broker (both are ActiveMQ).

I've tried numerous setups, none worked yet. The primary JBoss server
processes a request, then uses a ActiveMQ client to ultimately call a
producer.send() to the queue. Currently the queues on the local and remote
server are named the same thing. I tried making them different with no
affect, but that could be an issue.

Currently, the messages are being "balanced" between the primary and the
secondary. So first message goes to the primary queue, the second goes to
the secondary queue. Clearly the bridge is functioning, but not the way I'd
want.  I'd like message one and two to both exist in the local and remote
queue.

Here is the partial setup on the primary server.

<jmsBridgeConnectors>
  <jmsQueueConnector outboundQueueConnectionFactory="#remoteFactory">                
    <inboundQueueBridges>
      <inboundQueueBridge inboundQueueName = "importRequestQueue"
localQueueName = "importRequestQueue"/>
    </inboundQueueBridges>
    <outboundQueueBridges>
       <outboundQueueBridge outboundQueueName = "importRequestQueue"
localQueueName = "importRequestQueue"/>
    </outboundQueueBridges>
  </jmsQueueConnector>
</jmsBridgeConnectors>

<destinations>
  <queue physicalName="importRequestQueue"/>    
</destinations>

<transportConnector name="primary" uri="tcp://10.10.10.1:61616"/>

<bean id="remoteFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
  <property name="brokerURL" value="tcp://10.10.10.2:61666" />
</bean>
The secondary server currently has just this. I tried adding the JMS bridge
on this side too, but it didn't seem to change the behavior.

<destinations>
  <queue physicalName="importRequestQueue"/>    
</destinations>

<transportConnector name="secondary" uri="tcp://10.10.10.2:61616"/>
I've seen posts that seem to indicate the bridge works as I expect. Perhaps
I am missing some additional configuration?

I've also experimented with NetworkConnector settings, and even
programatically creating a ForwardingBridge, but haven't been able to create
the desired behavior.  It seems like any of these options should work, but
I'm stuck.

Any help would be greatly appreciated.



--
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-Bridge-trying-to-copy-all-messages-to-remote-server-tp4659769.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: JMS Bridge - trying to copy all messages to remote server

Posted by javatestcase <ja...@yahoo.com>.
I'm getting the same behavior using networkConnector as well.  Here is the
setup I'm currently trying (I switched to using vm://localhost.)

<transportConnectors>
	<transportConnector name="bxtpc" uri="vm://localhost"/>
</transportConnectors>
		
<networkConnectors>
	<networkConnector uri="static:(tcp://10.10.10.2:61616)"/>
</networkConnectors>

This one is clearly connecting as well:

17:32:19,530 INFO  [DiscoveryNetworkConnector] Establishing network
connection from vm://localhost?async=false&network=true to
tcp://10.10.10.2:61616

17:32:19,753 INFO  [DemandForwardingBridgeSupport] Network connection
between vm://localhost and tcp:///10.10.10.2:61616@40224(soaqa002) has been
established.

Seems like the bridge is connected.  I can see every other request hitting
break points in DemandForwardingBridgeSupport, but half the request never
do.

Any input is appreciated.



--
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-Bridge-trying-to-copy-all-messages-to-remote-server-tp4659769p4659787.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: JMS Bridge - trying to copy all messages to remote server

Posted by javatestcase <ja...@yahoo.com>.
Thanks Tim,

I've been looking at Camel for a while as a ESB (or ESB-like) solution in
general.  This seems like a great opportunity to try it out in my
application.



--
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-Bridge-trying-to-copy-all-messages-to-remote-server-tp4659769p4659958.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: JMS Bridge - trying to copy all messages to remote server

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2012-11-28 at 13:34 -0800, javatestcase wrote: 
> Well, thanks to Torsten, I was able to get onto a path that worked.
> 
> My solution actually ended out being two producers writing the same message
> to two separate queues (lets say queueLocal and queueRemote).  One queue is
> bridged to the remote server, where there is a consumer MBD listening on
> queueRemote.  A local MDB consuming queueLocal.  That way each queue has
> only a single consumer.

You might be able to make things a bit easier on the producer side by
having a little Camel route in the local broker that uses the Camel
multicast to send the message both to the local and remotely bridged
destination, see: 

http://camel.apache.org/multicast.html

and:

http://activemq.apache.org/enterprise-integration-patterns.html 

> 
> Both MDB are identical, but listening to different queues.  This creates the
> desired effect of the "same" message being consumer locally then remotely.
> 
> I suspect there is a more elegant solution to this problem, but this works. 
> The biggest downside so far is basically having to different versions of my
> consumer application, so the MDB can be listening on one queue locally, and
> a different one remotely (MDB are not very dynamic).  The solution to that
> might be trying to not use MDB.
> 
> 
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/JMS-Bridge-trying-to-copy-all-messages-to-remote-server-tp4659769p4659906.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

-- 
Tim Bish
Sr Software Engineer | RedHat Inc.
tim.bish@redhat.com | www.fusesource.com | www.redhat.com 
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/


Re: JMS Bridge - trying to copy all messages to remote server

Posted by javatestcase <ja...@yahoo.com>.
Well, thanks to Torsten, I was able to get onto a path that worked.

My solution actually ended out being two producers writing the same message
to two separate queues (lets say queueLocal and queueRemote).  One queue is
bridged to the remote server, where there is a consumer MBD listening on
queueRemote.  A local MDB consuming queueLocal.  That way each queue has
only a single consumer.

Both MDB are identical, but listening to different queues.  This creates the
desired effect of the "same" message being consumer locally then remotely.

I suspect there is a more elegant solution to this problem, but this works. 
The biggest downside so far is basically having to different versions of my
consumer application, so the MDB can be listening on one queue locally, and
a different one remotely (MDB are not very dynamic).  The solution to that
might be trying to not use MDB.



--
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-Bridge-trying-to-copy-all-messages-to-remote-server-tp4659769p4659906.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: JMS Bridge - trying to copy all messages to remote server

Posted by javatestcase <ja...@yahoo.com>.
Thanks for your answer Torsten.

Yes, I have a local consumer, as well as a remote consumer.  It sounds like
this is not the correct design to do what I am trying to do (cause the
message to be consumed both on the local server, and the remote server.)

The strategy I am aiming for is write to the local queue, and consume the
message.  Then copy to the message to the unreliable remote queue (retrying
until success) then consuming the message there as well.

It sounds like I need two separate queue, each with it's own consumer to
make this succeed?  Perhaps setting up a JMS connector with a different
queue name than the local queue will work?

<jmsBridgeConnectors>
  <jmsQueueConnector outboundQueueConnectionFactory="#remoteFactory">                
    <inboundQueueBridges>
      <inboundQueueBridge inboundQueueName = "importRequestQueueREMOTE"
localQueueName = "importRequestQueue"/>
    </inboundQueueBridges>
    <outboundQueueBridges>
       <outboundQueueBridge outboundQueueName = "importRequestQueueREMOTE"
 localQueueName = "importRequestQueue"/>
    </outboundQueueBridges>
  </jmsQueueConnector>
</jmsBridgeConnectors> 

Then the local server would have a consumer for importRequestQueue, and the
remote server would only have a consumer for importRequestQueueREMOTE. 

I don't see how I could create the desired behavior with NetworkConnector,
but perhaps with (Static/Dynamic)IncludedDestinations.

I'll go try that out now.  Let me know if there anyone can think a better
way to do this.



--
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-Bridge-trying-to-copy-all-messages-to-remote-server-tp4659769p4659836.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: JMS Bridge - trying to copy all messages to remote server

Posted by Torsten Mielke <to...@fusesource.com>.
Hello,

Do you have a local consumer connected to your queue on the local broker?
The fact that only every second message seems to be passed to the remote broker, suggests this.

If you have multiple consumers on a particular queue, then messages get pushed to consumers in a round robin fashion. Could this be your problem? 

Regards,

Torsten Mielke
torsten@fusesource.com
tmielke.blogspot.com


On Nov 26, 2012, at 9:41 PM, javatestcase wrote:

> Been trying to get ActiveMQ 5.7.0 running on JBossAS 5.1.0 set up to use a
> JMS to JMS bridge to copy every message from a queue on the local broker to
> a remote broker (both are ActiveMQ).
> 
> I've tried numerous setups, none worked yet. The primary JBoss server
> processes a request, then uses a ActiveMQ client to ultimately call a
> producer.send() to the queue. Currently the queues on the local and remote
> server are named the same thing. I tried making them different with no
> affect, but that could be an issue.
> 
> Currently, the messages are being "balanced" between the primary and the
> secondary. So first message goes to the primary queue, the second goes to
> the secondary queue. Clearly the bridge is functioning, but not the way I'd
> want.  I'd like message one and two to both exist in the local and remote
> queue.
> 
> Here is the partial setup on the primary server.
> 
> <jmsBridgeConnectors>
>  <jmsQueueConnector outboundQueueConnectionFactory="#remoteFactory">                
>    <inboundQueueBridges>
>      <inboundQueueBridge inboundQueueName = "importRequestQueue"
> localQueueName = "importRequestQueue"/>
>    </inboundQueueBridges>
>    <outboundQueueBridges>
>       <outboundQueueBridge outboundQueueName = "importRequestQueue"
> localQueueName = "importRequestQueue"/>
>    </outboundQueueBridges>
>  </jmsQueueConnector>
> </jmsBridgeConnectors>
> 
> <destinations>
>  <queue physicalName="importRequestQueue"/>    
> </destinations>
> 
> <transportConnector name="primary" uri="tcp://10.10.10.1:61616"/>
> 
> <bean id="remoteFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>  <property name="brokerURL" value="tcp://10.10.10.2:61666" />
> </bean>
> The secondary server currently has just this. I tried adding the JMS bridge
> on this side too, but it didn't seem to change the behavior.
> 
> <destinations>
>  <queue physicalName="importRequestQueue"/>    
> </destinations>
> 
> <transportConnector name="secondary" uri="tcp://10.10.10.2:61616"/>
> I've seen posts that seem to indicate the bridge works as I expect. Perhaps
> I am missing some additional configuration?
> 
> I've also experimented with NetworkConnector settings, and even
> programatically creating a ForwardingBridge, but haven't been able to create
> the desired behavior.  It seems like any of these options should work, but
> I'm stuck.
> 
> Any help would be greatly appreciated.
> 
> 
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/JMS-Bridge-trying-to-copy-all-messages-to-remote-server-tp4659769.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.