You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Jeffrey Bride <jb...@redhat.com> on 2009/02/07 05:42:55 UTC

Java client bindings on JBoss ESB

Hi,
  I'm currently working on an AMQP gateway for the JBoss ESB using the
QPid Java client libraries.  I have gotten it to work ... but did
experience a few issues along the way.  I made modifications to the
JBoss ESB to accommodate the problem I was experiencing.  Please see the
ESB forum post for details :

http://www.jboss.com/index.html?module=bb&op=viewtopic&t=150019

greatly appreciate any insights from experts on this list!


jeff


-- 
Jeffrey Bride
RedHat / JBoss
303-523-7885



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Java client bindings on JBoss ESB

Posted by Jeffrey Bride <jb...@redhat.com>.
Excellent !  Thank you Robert.
Your suggestion works!

jeff


On Sat, 2009-02-07 at 11:53 +0000, Robert Greig wrote:
> Hi Jeff,
> 
> >  I'm currently working on an AMQP gateway for the JBoss ESB using the
> > QPid Java client libraries.  I have gotten it to work ... but did
> > experience a few issues along the way.  I made modifications to the
> > JBoss ESB to accommodate the problem I was experiencing.  Please see the
> > ESB forum post for details :
> >
> > http://www.jboss.com/index.html?module=bb&op=viewtopic&t=150019
> 
> The idea is that when you are referring to connection factories or
> destinations you don't include the prefix "destination" or
> "connectionfactory". So in your example you should make the following
> change:
> 
> <jms-provider name="JMS"
> connection-factory="connectionfactory.qpidConnectionFactory">
>               <property name="jndi-prefixes"
> value="connectionfactory.,destination." />
>               <property name="java.naming.factory.initial"
> value="org.apache.qpid.jndi.PropertiesFileInitialContextFactory"/>
>               <property name="connectionfactory.qpidConnectionFactory"
>    value="amqp://guest:guest@clientId/virtualHost?brokerlist='tcp://ratwater:5672'"/>
>               <property name="destination.Alpha_Co"
> value="direct://usmc.tracks/Alpha_Co_queue?routingkey='Alpha_Co_key'"/>
>               <jms-bus busid="quickstartGwChannel">
>                   <jms-message-filter dest-type="QUEUE"
> dest-name="Alpha_Co" /><!-- NOTE THE CHANGE ON THIS LINE -->
>               </jms-bus>
> </jms-provider>
> 
> The reason for having prefixes is that the config is just simple
> name/value pairs and there is no other way to distinguish the "type"
> of the item being defined. This is even the case in the example above
> - for example, the connection factory is not distinguishable from the
> destination unless you want to attempt to parse each item and figure
> it out which is messy.
> 
> However when looking up the items from JNDI it is redundant to keep
> the prefix, so you don't use them. If you migrate to using an LDAP
> server for example, which allows a hierarchy for the names, you would
> not want to have to put prefixes in the names (or change the rest of
> your config or code to change the lookup name).
> 
> ActiveMQ also does this. I am not sure about other providers (which
> may or may not provide a properties file facade for JNDI).
> 
> I hope this clarifies things.
> 
> Robert
-- 
Jeffrey Bride
RedHat / JBoss
303-523-7885



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Java client bindings on JBoss ESB

Posted by Arnaud Simon <as...@redhat.com>.
Hi Jeffrey,

Jeffrey Bride wrote:
> Hi Arnaud,
>   great suggestion ... that approach also works .... unless the
> amqp.properties is included in the ESB archive.  In JBoss, property
> files are typically packaged in the root of any type of JEE (*.jar) or
> JBoss specific archive (*.esb, *.sar).  Subsequently, those property
> files end up in the classpath of the classloader that deployed the
> archive.  So, as an example, the following change in the
> getInitialContext method of PropertiesFileInitialContextFactory.java
> allows an amqp.properties file to be found when packaged in an ESB
> archive :
>
> p.load(this.getClass().getResourceAsStream(file));
>
> Personally, I can move forward without this being addressed.  But, my
> guess is that locating the amqp.properties in the classpath of the JBoss
> classloader might want to be considered.
>
>   
You are right, I have created a JIRA (qpid-1657) for that.

Thanks

Arnaud

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Java client bindings on JBoss ESB

Posted by Jeffrey Bride <jb...@redhat.com>.
Hi Arnaud,
  great suggestion ... that approach also works .... unless the
amqp.properties is included in the ESB archive.  In JBoss, property
files are typically packaged in the root of any type of JEE (*.jar) or
JBoss specific archive (*.esb, *.sar).  Subsequently, those property
files end up in the classpath of the classloader that deployed the
archive.  So, as an example, the following change in the
getInitialContext method of PropertiesFileInitialContextFactory.java
allows an amqp.properties file to be found when packaged in an ESB
archive :

p.load(this.getClass().getResourceAsStream(file));

Personally, I can move forward without this being addressed.  But, my
guess is that locating the amqp.properties in the classpath of the JBoss
classloader might want to be considered.

thanks again!

jeff

On Mon, 2009-02-09 at 09:43 +0100, Arnaud Simon wrote:

> Robert Greig wrote:
> > Hi Jeff,
> >
> >   
> >>  I'm currently working on an AMQP gateway for the JBoss ESB using the
> >> QPid Java client libraries.  I have gotten it to work ... but did
> >> experience a few issues along the way.  I made modifications to the
> >> JBoss ESB to accommodate the problem I was experiencing.  Please see the
> >> ESB forum post for details :
> >>
> >> http://www.jboss.com/index.html?module=bb&op=viewtopic&t=150019
> >>     
> Hi Jeff,
> 
> Another solution would be for you to use the property 
> java.naming.provider./url /to specify the path to a qpid property file.
> 
> <jms-provider name="JMS"
> connection-factory="connectionfactory.qpidConnectionFactory">
>     <property name="java.naming.provider./url/" value="file://path/qpid.jndi" />
>     <property name="qpidConnectionFactory" value=""/>    
>     <jms-bus busid="quickstartGwChannel">
>         <jms-message-filter dest-type="QUEUE" dest-name="Alpha_Co" />
>     </jms-bus>
> </jms-provider>
> 
> the file /path/qpid.jndi would look like:
> 
> ava.naming.factory.initial=org.apache.qpid.jndi.PropertiesFileInitialContextFactory
> connectionfactory.qpidConnectionFactory=amqp://guest:guest@clientId/virtualHost?brokerlist='tcp://ratwater:5672'
> destination.Alpha_Co=direct://usmc.tracks/Alpha_Co_queue?routingkey='Alpha_Co_key'
> 
> This should work with the existing ESB code as the connection factory is defined in qpid.jndi and the name of it through your ESB
> xml file.
> 
> Arnaud
>  
> 
> 
> 

-- 
Jeffrey Bride
RedHat / JBoss
303-523-7885


Re: Java client bindings on JBoss ESB

Posted by Jeffrey Bride <jb...@redhat.com>.
Hi,
  I see the change was made to
PropertiesFileInitialContextFactory.java ..... thank you !

I apologize for the confusion .... but as it turns out ..... in some
situations I can't pass the file name with a '/' prefix .... in which
case the existing code in trunk will not find the properties file.  The
following is an unfortunate hack to get the QPid client to work under
all circumstances in the JBoss ESB :

try {
          p.load(this.getClass().getResourceAsStream(file));
} catch(NullPointerException npe) {
         _logger.info("trying again with file = /"+file);
         p.load(this.getClass().getResourceAsStream("/"+file));
}

I can elaborate further on the issue I'm experiencing between JBoss ESB
and QPid if interested.

Arnaud :  I will continue to take your advice into consideration.  I do
currently like the idea of consolidating qpid specific properties in
this file.  I reference this file from several different places in my
application.   

thanks again!  jeff


On Tue, 2009-02-10 at 20:07 +0000, Robert Greig wrote:

> 2009/2/9 Arnaud Simon <as...@redhat.com>:
> 
> > Another solution would be for you to use the property
> > java.naming.provider./url /to specify the path to a qpid property file.
> 
> My advice for this is for people to think about where they want to
> consolidate configuration.
> 
> If you have a configuration file for this purpose, is there any reason
> to introduce yet another file for people to maintain?
> 
> The properties file is useful for scenarios where you don't have
> anywhere else that is useful to store than information or where for
> some reason (e.g. delegation of responsibility) you want to separate
> it from other configuration.
> 
> RG

-- 
Jeffrey Bride
RedHat / JBoss
303-523-7885


Re: Java client bindings on JBoss ESB

Posted by Robert Greig <ro...@gmail.com>.
2009/2/9 Arnaud Simon <as...@redhat.com>:

> Another solution would be for you to use the property
> java.naming.provider./url /to specify the path to a qpid property file.

My advice for this is for people to think about where they want to
consolidate configuration.

If you have a configuration file for this purpose, is there any reason
to introduce yet another file for people to maintain?

The properties file is useful for scenarios where you don't have
anywhere else that is useful to store than information or where for
some reason (e.g. delegation of responsibility) you want to separate
it from other configuration.

RG

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Java client bindings on JBoss ESB

Posted by Carl Trieloff <cc...@redhat.com>.
Arnaud Simon wrote:
> Robert Greig wrote:
>> Hi Jeff,
>>
>>  
>>>  I'm currently working on an AMQP gateway for the JBoss ESB using the
>>> QPid Java client libraries.  I have gotten it to work ... but did
>>> experience a few issues along the way.  I made modifications to the
>>> JBoss ESB to accommodate the problem I was experiencing.  Please see 
>>> the
>>> ESB forum post for details :
>>>
>>> http://www.jboss.com/index.html?module=bb&op=viewtopic&t=150019
>>>     
> Hi Jeff,
>
> Another solution would be for you to use the property 
> java.naming.provider./url /to specify the path to a qpid property file.
>
> <jms-provider name="JMS"
> connection-factory="connectionfactory.qpidConnectionFactory">
>    <property name="java.naming.provider./url/" 
> value="file://path/qpid.jndi" />
>    <property name="qpidConnectionFactory" value=""/>       <jms-bus 
> busid="quickstartGwChannel">
>        <jms-message-filter dest-type="QUEUE" dest-name="Alpha_Co" />
>    </jms-bus>
> </jms-provider>
>
> the file /path/qpid.jndi would look like:
>
> ava.naming.factory.initial=org.apache.qpid.jndi.PropertiesFileInitialContextFactory 
>
> connectionfactory.qpidConnectionFactory=amqp://guest:guest@clientId/virtualHost?brokerlist='tcp://ratwater:5672' 
>
> destination.Alpha_Co=direct://usmc.tracks/Alpha_Co_queue?routingkey='Alpha_Co_key' 
>
>
> This should work with the existing ESB code as the connection factory 
> is defined in qpid.jndi and the name of it through your ESB
> xml file.
>
> Arnaud
>
>
>
>
>


If someone wants to blog or post the how-to to do this, I will add it to 
the FAQ.

Carl.




---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Java client bindings on JBoss ESB

Posted by Arnaud Simon <as...@redhat.com>.
Robert Greig wrote:
> Hi Jeff,
>
>   
>>  I'm currently working on an AMQP gateway for the JBoss ESB using the
>> QPid Java client libraries.  I have gotten it to work ... but did
>> experience a few issues along the way.  I made modifications to the
>> JBoss ESB to accommodate the problem I was experiencing.  Please see the
>> ESB forum post for details :
>>
>> http://www.jboss.com/index.html?module=bb&op=viewtopic&t=150019
>>     
Hi Jeff,

Another solution would be for you to use the property 
java.naming.provider./url /to specify the path to a qpid property file.

<jms-provider name="JMS"
connection-factory="connectionfactory.qpidConnectionFactory">
    <property name="java.naming.provider./url/" value="file://path/qpid.jndi" />
    <property name="qpidConnectionFactory" value=""/>    
    <jms-bus busid="quickstartGwChannel">
        <jms-message-filter dest-type="QUEUE" dest-name="Alpha_Co" />
    </jms-bus>
</jms-provider>

the file /path/qpid.jndi would look like:

ava.naming.factory.initial=org.apache.qpid.jndi.PropertiesFileInitialContextFactory
connectionfactory.qpidConnectionFactory=amqp://guest:guest@clientId/virtualHost?brokerlist='tcp://ratwater:5672'
destination.Alpha_Co=direct://usmc.tracks/Alpha_Co_queue?routingkey='Alpha_Co_key'

This should work with the existing ESB code as the connection factory is defined in qpid.jndi and the name of it through your ESB
xml file.

Arnaud
 




Re: Java client bindings on JBoss ESB

Posted by Robert Greig <ro...@gmail.com>.
Hi Jeff,

>  I'm currently working on an AMQP gateway for the JBoss ESB using the
> QPid Java client libraries.  I have gotten it to work ... but did
> experience a few issues along the way.  I made modifications to the
> JBoss ESB to accommodate the problem I was experiencing.  Please see the
> ESB forum post for details :
>
> http://www.jboss.com/index.html?module=bb&op=viewtopic&t=150019

The idea is that when you are referring to connection factories or
destinations you don't include the prefix "destination" or
"connectionfactory". So in your example you should make the following
change:

<jms-provider name="JMS"
connection-factory="connectionfactory.qpidConnectionFactory">
              <property name="jndi-prefixes"
value="connectionfactory.,destination." />
              <property name="java.naming.factory.initial"
value="org.apache.qpid.jndi.PropertiesFileInitialContextFactory"/>
              <property name="connectionfactory.qpidConnectionFactory"
   value="amqp://guest:guest@clientId/virtualHost?brokerlist='tcp://ratwater:5672'"/>
              <property name="destination.Alpha_Co"
value="direct://usmc.tracks/Alpha_Co_queue?routingkey='Alpha_Co_key'"/>
              <jms-bus busid="quickstartGwChannel">
                  <jms-message-filter dest-type="QUEUE"
dest-name="Alpha_Co" /><!-- NOTE THE CHANGE ON THIS LINE -->
              </jms-bus>
</jms-provider>

The reason for having prefixes is that the config is just simple
name/value pairs and there is no other way to distinguish the "type"
of the item being defined. This is even the case in the example above
- for example, the connection factory is not distinguishable from the
destination unless you want to attempt to parse each item and figure
it out which is messy.

However when looking up the items from JNDI it is redundant to keep
the prefix, so you don't use them. If you migrate to using an LDAP
server for example, which allows a hierarchy for the names, you would
not want to have to put prefixes in the names (or change the rest of
your config or code to change the lookup name).

ActiveMQ also does this. I am not sure about other providers (which
may or may not provide a properties file facade for JNDI).

I hope this clarifies things.

Robert

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org