activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kubofary <jfar...@gmail.com>
Subject JMS Bridge to third party broker providing only ConnectionFactory
Date Tue, 16 Sep 2014 11:37:48 GMT
Hello,
I need to establish a JMS to JMS bridge between ActiveMQ and a third party
JMS broker (webMethods broker). The remote system provides a
ConnectionFactory and several Destinations (instances of javax.jms.Queue)
through JNDI.
I tried to follow the example at
http://activemq.apache.org/jms-to-jms-bridge.html , but I haven't found a
way to instantiate the inbound and outbound queue bridges using the generic
javax.jms.ConnectionFactory. Even looking at the code in
org.apache.activemq.network.jms.JmsConnector and
org.apache.activemq.network.jms.JmsQueueConnector, it seams that I need an
instance of javax.jms.QueueConnectionFactory.

For example,I can read from the remote queue using a simple java client like
this (without needing to know that it is a Queue at all):

ConnectionFactory myConnFactory = (ConnectionFactory)
namingContext.lookup(CONNECTIONFACTORY_NAME);
Destination queue = (Destination) namingContext.lookup(REMOTE_QUEUE_NAME);
Connection conn = myConnFactory.createConnection();
conn.start();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queue);
Message message = consumer.receive();

I need to map this remote Destination to a local ActiveMQ Queue, so that my
application is decoupled from the remote JMS broker and ActiveMQ acts as a
proxy.
Normally, I would do something like:
  <jmsBridgeConnectors>
    <jmsQueueConnector 
        jndiOutboundTemplate="#jndiLookupFactory"   
        outboundQueueConnectionFactoryName="CONNECTIONFACTORY_NAME">
      <inboundQueueBridges>
        <inboundQueueBridge 
            inboundQueueName = "REMOTE_QUEUE_NAME" 
            localQueueName   = "LOCAL_QUEUE_NAME" />
      </inboundQueueBridges>
    </jmsQueueConnector>
  </jmsBridgeConnectors>

    <bean id="remoteJndi" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
                <props>
                        ...
                </props>
        </property>
    </bean>

    <bean id="jndiLookupFactory"
class="org.apache.activemq.network.jms.JndiTemplateLookupFactory">
        <constructor-arg ref="remoteJndi" />
    </bean>

But this apparently doesn't work, because I only get a ConnectionFactory
instance, while JmsQueueConnector is expecting a QueueConnectionFactory.

I was thinking about using a DelegatingConnectionFactory from Spring, but
that still wouldn't work, because the returned Connections still wouldn't be
QueueConnection implementations.

Is there a way to do this simply by configuring activemq.xml differently, or
do I need to implement my own implementations of QueueConnectionFactory,
QueueConnection, and QueueSession that would delegate the calls to queue
specific methods to the generic methods in ConnectionFactory, Connection,
and Session?

Thank you




--
View this message in context: http://activemq.2283324.n4.nabble.com/JMS-Bridge-to-third-party-broker-providing-only-ConnectionFactory-tp4685576.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message