You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by agrabil <gr...@ins.com> on 2006/08/01 18:31:08 UTC

Re: JMS to JMS Bridge

Hello,
I believe that I have identified the issue with this particular problem.  It
appears that the code in the JmsQueueConnector class assumes that the name
of the outboundQueueName is also the name of the local (ActiveMQ) queue.  In
this situation, this is not the case.  In fact, as SwiftMQ requires a naming
convention of "queueName@router", which is not a valid queue name for
ActiveMQ.  I believe that this same problem could occur with the
InboundQueueBridge as well.  I have implemented a fix, which I would like to
confirm is appropriate.  First, I added a 'localQueueName' property to both
the InboundQueueBridge and OutboundQueueBridge classes, along with the
customary getter/setter.  Then, in the JmsQueueConnection class, I modified
the initializeInboundQueueBridges and initializeOutboundQueueBridges to
obtain the localQueueName from the Inbound/OutboundQueueBridge and set that
for the ActiveMQ queue name:


    protected void initializeInboundQueueBridges() throws JMSException{
        if(inboundQueueBridges!=null){
            QueueSession outboundSession =
outboundQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
            QueueSession localSession =
localQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
            for(int i=0;i<inboundQueueBridges.length;i++){
                InboundQueueBridge bridge=inboundQueueBridges[i];
                String localQueueName = bridge.getLocalQueueName();
                Queue
activemqQueue=createActiveMQQueue(localSession,localQueueName);
                String queueName=bridge.getInboundQueueName();
                Queue
foreignQueue=createForeignQueue(outboundSession,queueName);
                bridge.setConsumerQueue(foreignQueue);
                bridge.setProducerQueue(activemqQueue);
                bridge.setProducerConnection(localQueueConnection);
                bridge.setConsumerConnection(outboundQueueConnection);
                if(bridge.getJmsMessageConvertor()==null){
                   
bridge.setJmsMessageConvertor(getInboundMessageConvertor());
                }
                bridge.setJmsConnector(this);
                addInboundBridge(bridge);
            }
            outboundSession.close();
            localSession.close();
        }
    }

    protected void initializeOutboundQueueBridges() throws JMSException{
        if(outboundQueueBridges!=null){
            QueueSession outboundSession =
outboundQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
            QueueSession localSession =
localQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
            for(int i=0;i<outboundQueueBridges.length;i++){
                OutboundQueueBridge bridge=outboundQueueBridges[i];
                String localQueueName=bridge.getLocalQueueName();
                Queue
activemqQueue=createActiveMQQueue(localSession,localQueueName);
                String queueName=bridge.getOutboundQueueName();
                Queue
foreignQueue=createForeignQueue(outboundSession,queueName);
                bridge.setConsumerQueue(activemqQueue);
                bridge.setProducerQueue(foreignQueue);
                bridge.setProducerConnection(outboundQueueConnection);
                bridge.setConsumerConnection(localQueueConnection);
                if(bridge.getJmsMessageConvertor()==null){
                   
bridge.setJmsMessageConvertor(getOutboundMessageConvertor());
                }
                bridge.setJmsConnector(this);
                addOutboundBridge(bridge);
            }
            outboundSession.close();
            localSession.close();
        }
    }

I have not committed changes to any open source projects before, so I am not
familiar with the process.  If these changes appear to be acceptable, please
let me know how to proceed.  Perhaps someone with developer credentials for
the project can simply incorporate these changes in a future build?

Thanks,
Greg Rabil
-- 
View this message in context: http://www.nabble.com/JMS-to-JMS-Bridge-tf1901141.html#a5598132
Sent from the ActiveMQ - User forum at Nabble.com.


Re: JMS to JMS Bridge

Posted by James Strachan <ja...@gmail.com>.
Great stuff! Welcome Greg!

Here's an introduction into how to contribute & create patches and so forth...

http://incubator.apache.org/activemq/contributing.html


On 8/1/06, agrabil <gr...@ins.com> wrote:
>
> Hello,
> I believe that I have identified the issue with this particular problem.  It
> appears that the code in the JmsQueueConnector class assumes that the name
> of the outboundQueueName is also the name of the local (ActiveMQ) queue.  In
> this situation, this is not the case.  In fact, as SwiftMQ requires a naming
> convention of "queueName@router", which is not a valid queue name for
> ActiveMQ.  I believe that this same problem could occur with the
> InboundQueueBridge as well.  I have implemented a fix, which I would like to
> confirm is appropriate.  First, I added a 'localQueueName' property to both
> the InboundQueueBridge and OutboundQueueBridge classes, along with the
> customary getter/setter.  Then, in the JmsQueueConnection class, I modified
> the initializeInboundQueueBridges and initializeOutboundQueueBridges to
> obtain the localQueueName from the Inbound/OutboundQueueBridge and set that
> for the ActiveMQ queue name:
>
>
>     protected void initializeInboundQueueBridges() throws JMSException{
>         if(inboundQueueBridges!=null){
>             QueueSession outboundSession =
> outboundQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
>             QueueSession localSession =
> localQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
>             for(int i=0;i<inboundQueueBridges.length;i++){
>                 InboundQueueBridge bridge=inboundQueueBridges[i];
>                 String localQueueName = bridge.getLocalQueueName();
>                 Queue
> activemqQueue=createActiveMQQueue(localSession,localQueueName);
>                 String queueName=bridge.getInboundQueueName();
>                 Queue
> foreignQueue=createForeignQueue(outboundSession,queueName);
>                 bridge.setConsumerQueue(foreignQueue);
>                 bridge.setProducerQueue(activemqQueue);
>                 bridge.setProducerConnection(localQueueConnection);
>                 bridge.setConsumerConnection(outboundQueueConnection);
>                 if(bridge.getJmsMessageConvertor()==null){
>
> bridge.setJmsMessageConvertor(getInboundMessageConvertor());
>                 }
>                 bridge.setJmsConnector(this);
>                 addInboundBridge(bridge);
>             }
>             outboundSession.close();
>             localSession.close();
>         }
>     }
>
>     protected void initializeOutboundQueueBridges() throws JMSException{
>         if(outboundQueueBridges!=null){
>             QueueSession outboundSession =
> outboundQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
>             QueueSession localSession =
> localQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
>             for(int i=0;i<outboundQueueBridges.length;i++){
>                 OutboundQueueBridge bridge=outboundQueueBridges[i];
>                 String localQueueName=bridge.getLocalQueueName();
>                 Queue
> activemqQueue=createActiveMQQueue(localSession,localQueueName);
>                 String queueName=bridge.getOutboundQueueName();
>                 Queue
> foreignQueue=createForeignQueue(outboundSession,queueName);
>                 bridge.setConsumerQueue(activemqQueue);
>                 bridge.setProducerQueue(foreignQueue);
>                 bridge.setProducerConnection(outboundQueueConnection);
>                 bridge.setConsumerConnection(localQueueConnection);
>                 if(bridge.getJmsMessageConvertor()==null){
>
> bridge.setJmsMessageConvertor(getOutboundMessageConvertor());
>                 }
>                 bridge.setJmsConnector(this);
>                 addOutboundBridge(bridge);
>             }
>             outboundSession.close();
>             localSession.close();
>         }
>     }
>
> I have not committed changes to any open source projects before, so I am not
> familiar with the process.  If these changes appear to be acceptable, please
> let me know how to proceed.  Perhaps someone with developer credentials for
> the project can simply incorporate these changes in a future build?
>
> Thanks,
> Greg Rabil
> --
> View this message in context: http://www.nabble.com/JMS-to-JMS-Bridge-tf1901141.html#a5598132
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 

James
-------
http://radio.weblogs.com/0112098/

Re: JMS to JMS Bridge

Posted by Rob Davies <ra...@gmail.com>.
I'll do it as I was in the middle of looking at this anyways - I'm  
going to link back to this conversation though on the commit log

cheers,

Rob



Rob Davies
http://rajdavies.blogspot.com/



On 1 Aug 2006, at 17:46, agrabil wrote:

>
> Great!  So, should I proceed with creating a JIRA ticket, etc. as  
> described
> in the link that James provided, or will you handle incorporating  
> this fix?
>
> Thanks,
> Greg
> -- 
> View this message in context: http://www.nabble.com/JMS-to-JMS- 
> Bridge-tf1901141.html#a5598457
> Sent from the ActiveMQ - User forum at Nabble.com.
>







Re: JMS to JMS Bridge

Posted by James Strachan <ja...@gmail.com>.
On 8/1/06, agrabil <gr...@ins.com> wrote:
> Thanks Rob.  BTW, I just thought that the implementation I provided may be
> improved to support backward compatability, and so as to not require the
> localQueueName attribute.  E.g.:
>
>                 ...
>                 String localQueueName = bridge.getLocalQueueName();
>                 if ((localQueueName == null) || (localQueueName.length() <=
> 0)) {
>                      localQueueName = bridge.getOutboundQueueName();
>                 }
>                 Queue
> activemqQueue=createActiveMQQueue(localSession,localQueueName);
>                 ...
>
> Of course, maybe you already thought of this! ;-)
>
> Thanks again, and I'm glad I could help.  I really needed this to work so I
> can migrate from SwiftMQ to ActiveMQ!

Its nice to hear from a SwiftMQ -> ActiveMQ switcher :)
-- 

James
-------
http://radio.weblogs.com/0112098/

Re: JMS to JMS Bridge

Posted by Rob Davies <ra...@gmail.com>.
Hi Greg,

that check is done in the bridges themselves - so if you don't set  
the localQueueName or localTopicName - it's been defaulted to the  
inboundQueueName/inboundTopicName etc.

cheers,

Rob
On 1 Aug 2006, at 19:13, agrabil wrote:

>
> Thanks Rob.  BTW, I just thought that the implementation I provided  
> may be
> improved to support backward compatability, and so as to not  
> require the
> localQueueName attribute.  E.g.:
>
>                 ...
>                 String localQueueName = bridge.getLocalQueueName();
>                 if ((localQueueName == null) ||  
> (localQueueName.length() <=
> 0)) {
>                      localQueueName = bridge.getOutboundQueueName();
>                 }
>                 Queue
> activemqQueue=createActiveMQQueue(localSession,localQueueName);
>                 ...
>
> Of course, maybe you already thought of this! ;-)
>
> Thanks again, and I'm glad I could help.  I really needed this to  
> work so I
> can migrate from SwiftMQ to ActiveMQ!
>
> Greg
> -- 
> View this message in context: http://www.nabble.com/JMS-to-JMS- 
> Bridge-tf1901141.html#a5600078
> Sent from the ActiveMQ - User forum at Nabble.com.
>


Re: JMS to JMS Bridge

Posted by agrabil <gr...@ins.com>.
Thanks Rob.  BTW, I just thought that the implementation I provided may be
improved to support backward compatability, and so as to not require the
localQueueName attribute.  E.g.:

                ...
                String localQueueName = bridge.getLocalQueueName();
                if ((localQueueName == null) || (localQueueName.length() <=
0)) {
                     localQueueName = bridge.getOutboundQueueName();
                }
                Queue
activemqQueue=createActiveMQQueue(localSession,localQueueName);
                ...

Of course, maybe you already thought of this! ;-)

Thanks again, and I'm glad I could help.  I really needed this to work so I
can migrate from SwiftMQ to ActiveMQ!

Greg
-- 
View this message in context: http://www.nabble.com/JMS-to-JMS-Bridge-tf1901141.html#a5600078
Sent from the ActiveMQ - User forum at Nabble.com.


Re: JMS to JMS Bridge

Posted by Rob Davies <ra...@gmail.com>.
ok - the changes are in - I'll update the documentation - thank you  
Greg for working on this.


cheers,

Rob

Rob Davies
http://rajdavies.blogspot.com/


On 1 Aug 2006, at 17:46, agrabil wrote:

>
> Great!  So, should I proceed with creating a JIRA ticket, etc. as  
> described
> in the link that James provided, or will you handle incorporating  
> this fix?
>
> Thanks,
> Greg
> -- 
> View this message in context: http://www.nabble.com/JMS-to-JMS- 
> Bridge-tf1901141.html#a5598457
> Sent from the ActiveMQ - User forum at Nabble.com.
>








Re: JMS to JMS Bridge

Posted by agrabil <gr...@ins.com>.
Great!  So, should I proceed with creating a JIRA ticket, etc. as described
in the link that James provided, or will you handle incorporating this fix?

Thanks,
Greg
-- 
View this message in context: http://www.nabble.com/JMS-to-JMS-Bridge-tf1901141.html#a5598457
Sent from the ActiveMQ - User forum at Nabble.com.


Re: JMS to JMS Bridge

Posted by Rob Davies <ra...@gmail.com>.
will give it a go a see if it breaks anything - thanks for the patch!

cheers,

Rob


Rob Davies
http://rajdavies.blogspot.com/


On 1 Aug 2006, at 17:31, agrabil wrote:

>
> Hello,
> I believe that I have identified the issue with this particular  
> problem.  It
> appears that the code in the JmsQueueConnector class assumes that  
> the name
> of the outboundQueueName is also the name of the local (ActiveMQ)  
> queue.  In
> this situation, this is not the case.  In fact, as SwiftMQ requires  
> a naming
> convention of "queueName@router", which is not a valid queue name for
> ActiveMQ.  I believe that this same problem could occur with the
> InboundQueueBridge as well.  I have implemented a fix, which I  
> would like to
> confirm is appropriate.  First, I added a 'localQueueName' property  
> to both
> the InboundQueueBridge and OutboundQueueBridge classes, along with the
> customary getter/setter.  Then, in the JmsQueueConnection class, I  
> modified
> the initializeInboundQueueBridges and  
> initializeOutboundQueueBridges to
> obtain the localQueueName from the Inbound/OutboundQueueBridge and  
> set that
> for the ActiveMQ queue name:
>
>
>     protected void initializeInboundQueueBridges() throws  
> JMSException{
>         if(inboundQueueBridges!=null){
>             QueueSession outboundSession =
> outboundQueueConnection.createQueueSession 
> (false,Session.AUTO_ACKNOWLEDGE);
>             QueueSession localSession =
> localQueueConnection.createQueueSession 
> (false,Session.AUTO_ACKNOWLEDGE);
>             for(int i=0;i<inboundQueueBridges.length;i++){
>                 InboundQueueBridge bridge=inboundQueueBridges[i];
>                 String localQueueName = bridge.getLocalQueueName();
>                 Queue
> activemqQueue=createActiveMQQueue(localSession,localQueueName);
>                 String queueName=bridge.getInboundQueueName();
>                 Queue
> foreignQueue=createForeignQueue(outboundSession,queueName);
>                 bridge.setConsumerQueue(foreignQueue);
>                 bridge.setProducerQueue(activemqQueue);
>                 bridge.setProducerConnection(localQueueConnection);
>                 bridge.setConsumerConnection(outboundQueueConnection);
>                 if(bridge.getJmsMessageConvertor()==null){
>
> bridge.setJmsMessageConvertor(getInboundMessageConvertor());
>                 }
>                 bridge.setJmsConnector(this);
>                 addInboundBridge(bridge);
>             }
>             outboundSession.close();
>             localSession.close();
>         }
>     }
>
>     protected void initializeOutboundQueueBridges() throws  
> JMSException{
>         if(outboundQueueBridges!=null){
>             QueueSession outboundSession =
> outboundQueueConnection.createQueueSession 
> (false,Session.AUTO_ACKNOWLEDGE);
>             QueueSession localSession =
> localQueueConnection.createQueueSession 
> (false,Session.AUTO_ACKNOWLEDGE);
>             for(int i=0;i<outboundQueueBridges.length;i++){
>                 OutboundQueueBridge bridge=outboundQueueBridges[i];
>                 String localQueueName=bridge.getLocalQueueName();
>                 Queue
> activemqQueue=createActiveMQQueue(localSession,localQueueName);
>                 String queueName=bridge.getOutboundQueueName();
>                 Queue
> foreignQueue=createForeignQueue(outboundSession,queueName);
>                 bridge.setConsumerQueue(activemqQueue);
>                 bridge.setProducerQueue(foreignQueue);
>                 bridge.setProducerConnection(outboundQueueConnection);
>                 bridge.setConsumerConnection(localQueueConnection);
>                 if(bridge.getJmsMessageConvertor()==null){
>
> bridge.setJmsMessageConvertor(getOutboundMessageConvertor());
>                 }
>                 bridge.setJmsConnector(this);
>                 addOutboundBridge(bridge);
>             }
>             outboundSession.close();
>             localSession.close();
>         }
>     }
>
> I have not committed changes to any open source projects before, so  
> I am not
> familiar with the process.  If these changes appear to be  
> acceptable, please
> let me know how to proceed.  Perhaps someone with developer  
> credentials for
> the project can simply incorporate these changes in a future build?
>
> Thanks,
> Greg Rabil
> -- 
> View this message in context: http://www.nabble.com/JMS-to-JMS- 
> Bridge-tf1901141.html#a5598132
> Sent from the ActiveMQ - User forum at Nabble.com.
>