You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Marsha Johnson <ma...@jpsco.com> on 2006/03/23 22:52:28 UTC

Accessing JMS resources from application client

HI,

I am using IBM Websphere Application Server Community Edition and I am trying 
to create a client application that will consume messages from a queue created 
from a deployment plan external to the application.  Both the queue and 
connection factory have been successfully deployed from the following plan:

<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.0"
configId="org/apache/geronimo/OPJmsPlan"
parentId="geronimo/activemq/1.0/car">
<resourceadapter>
<resourceadapter-instance>
<resourceadapter-name>OP JMS RA</resourceadapter-name>
<config-property-setting name="ServerUrl">tcp://0.0.0.0:61616</config-property-
setting>
<config-property-setting name="UserName">geronimo</config-property-setting>
<config-property-setting name="Password">geronimo</config-property-setting>
<workmanager>
<gbean-link>DefaultWorkManager</gbean-link>
</workmanager>
</resourceadapter-instance>
<outbound-resourceadapter>
<connection-definition>
<connectionfactory-interface>javax.jms.ConnectionFactory</connectionfactory-
interface>
<connectiondefinition-instance>
<name>jms/OPConnFactory1</name>
<implemented-interface>javax.jms.QueueConnectionFactory</implemented-interface>
<connectionmanager>
<xa-transaction>
<transaction-caching/>
</xa-transaction>
<single-pool>
<max-size>10</max-size>
<blocking-timeout-milliseconds>60000</blocking-timeout-milliseconds>
<match-one/>
</single-pool>
</connectionmanager>
</connectiondefinition-instance>
</connection-definition>
</outbound-resourceadapter>
</resourceadapter>
<adminobject>
 <adminobject-interface>javax.jms.Queue</adminobject-interface>
<adminobject-class>org.codehaus.activemq.message.ActiveMQQueue</adminobject-
class>
 <adminobject-instance>
   <message-destination-name>jms/OPQueue</message-destination-name>
   <config-property-setting name="PhysicalName">OPQueuePD</config-property-
setting>
 </adminobject-instance>
</adminobject>
</connector>


My application-client.xml deployment plan has the following code:

<resource-ref>
 <res-ref-name>jms/OPConnFactory1</res-ref-name>
 <res-type>javax.jms.QueueConnectionFactory</res-type>
 <res-auth>Container</res-auth>
 <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<message-destination-ref>
 <message-destination-ref-name>jms/OPQueue</message-destination-ref-name>
 <message-destination-type>javax.jms.Queue</message-destination-type>
 <message-destination-usage>Consumes</message-destination-usage>
 <message-destination-link>jms/OPQueue</message-destination-link>
</message-destination-ref>

<message-destination>
 <message-destination-name>jms/OPQueue</message-destination-name>
</message-destination>

My geronimo-application-client.xml deployment plan has the following code:

<naming:resource-ref>
  <naming:ref-name>jms/OPConnFactory1</naming:ref-name>
  <naming:resource-link>jms/OPConnFactory1</naming:resource-link>
</naming:resource-ref>

However, when I try to deploy I get the following message:
Error: Unable to distribute OPConsumer.ear: Unable to resolve
resource reference 'jms/OPConnFactory1' (no matching resources
found)


What am I doing wrong?



Re: Accessing JMS resources from application client

Posted by Aaron Mulder <am...@alumni.princeton.edu>.
The JMS resources actually live in the JMS server.  So if both the
Geronimo server and application client declare the same destinations,
then there will really only be one physical destination, living in the
JMS server, but both the Geronimo code and application client code
will be able to access it.  So a web service in the server can be a
producer while an application client can be the consumer or vice
versa.

Thanks,
    Aaron

On 3/24/06, Marsha Johnson <ma...@jpsco.com> wrote:
> Aaron Mulder <am...@...> writes:
>
> >
> > I don't think you can connect to a JMS resource living in the server
> > from an application client (nor can a client access a server-side JDBC
> > pool; an app client can only remotely access EJBs running in the
> > server).
> >
> > However, there is a trick whereby you essentailly configure the client
> > to independently connect to the same JMS server so it will still send
> > and receive messages using the same JMS topics/queues.  I believe what
> > you need to do in order to make this work is to add the kind of
> > settings that are in your connector deployment plan to your
> > geronimo-application-client.xml deployment plan, so the app client
> > also knows how to connect to the JMS server.  I don't have an example
> > of this, but I know there are some out there -- perhaps David J can
> > point you to one?
> >
> > Thanks,
> >     Aaron
> >
> > On 3/23/06, Marsha Johnson <ma...@...> wrote:
> > > HI,
> > >
> > > I am using IBM Websphere Application Server Community Edition and I am
> trying
> > > to create a client application that will consume messages from a queue
> created
> > > from a deployment plan external to the application.  Both the queue and
> > > connection factory have been successfully deployed from the following plan:
> > >
> > > <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.0"
> > > configId="org/apache/geronimo/OPJmsPlan"
> > > parentId="geronimo/activemq/1.0/car">
> > > <resourceadapter>
> > > ...........
> > > > > </connector>
> > >
> > > However, when I try to deploy I get the following message:
> > > Error: Unable to distribute OPConsumer.ear: Unable to resolve
> > > resource reference 'jms/OPConnFactory1' (no matching resources
> > > found)
> > >
> > >
> > > What am I doing wrong?
> > >
> > >
> > >
> >
> >
>
> Hi,
>
> Thank you so much for your suggestions.  They both seem to speak to building
> the connector in the geronimo-application-client plan though.  The problem is
> that it is a web service that pushes messages onto the queue and the
> application client(which by the way is a jar file packaged in an ear file)
> which should pop the messages from the queue, process them, and send them back
> to the web service.  If I build the JMS objects inside the application client,
> would the web service be able to find them?
>
> Also, I had tried importing my connector deployment plan into my ear's
> application.xml file.
>   <import><url>org/apache/geronimo/OPJmsPlan</uri></import>
>
> Then, I didn't get the error concerining not being able to find the JMS
> resources.  But when I tried to run the application client, I received a "Port
> in use exception; 1099" error.  This port is the java.naming.provider.url port
> for rmi.
>
> -- Marsha --
>
>
>
>
>

Re: Accessing JMS resources from application client

Posted by Marsha Johnson <ma...@jpsco.com>.
Aaron Mulder <am...@...> writes:

> 
> I don't think you can connect to a JMS resource living in the server
> from an application client (nor can a client access a server-side JDBC
> pool; an app client can only remotely access EJBs running in the
> server).
> 
> However, there is a trick whereby you essentailly configure the client
> to independently connect to the same JMS server so it will still send
> and receive messages using the same JMS topics/queues.  I believe what
> you need to do in order to make this work is to add the kind of
> settings that are in your connector deployment plan to your
> geronimo-application-client.xml deployment plan, so the app client
> also knows how to connect to the JMS server.  I don't have an example
> of this, but I know there are some out there -- perhaps David J can
> point you to one?
> 
> Thanks,
>     Aaron
> 
> On 3/23/06, Marsha Johnson <ma...@...> wrote:
> > HI,
> >
> > I am using IBM Websphere Application Server Community Edition and I am 
trying
> > to create a client application that will consume messages from a queue 
created
> > from a deployment plan external to the application.  Both the queue and
> > connection factory have been successfully deployed from the following plan:
> >
> > <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.0"
> > configId="org/apache/geronimo/OPJmsPlan"
> > parentId="geronimo/activemq/1.0/car">
> > <resourceadapter>
> > ...........
> > > > </connector>
> >
> > However, when I try to deploy I get the following message:
> > Error: Unable to distribute OPConsumer.ear: Unable to resolve
> > resource reference 'jms/OPConnFactory1' (no matching resources
> > found)
> >
> >
> > What am I doing wrong?
> >
> >
> >
> 
> 

Hi,

Thank you so much for your suggestions.  They both seem to speak to building 
the connector in the geronimo-application-client plan though.  The problem is 
that it is a web service that pushes messages onto the queue and the 
application client(which by the way is a jar file packaged in an ear file) 
which should pop the messages from the queue, process them, and send them back 
to the web service.  If I build the JMS objects inside the application client, 
would the web service be able to find them?

Also, I had tried importing my connector deployment plan into my ear's 
application.xml file.  
  <import><url>org/apache/geronimo/OPJmsPlan</uri></import>

Then, I didn't get the error concerining not being able to find the JMS 
resources.  But when I tried to run the application client, I received a "Port 
in use exception; 1099" error.  This port is the java.naming.provider.url port 
for rmi.

-- Marsha --





Re: Accessing JMS resources from application client

Posted by Aaron Mulder <am...@alumni.princeton.edu>.
I don't think you can connect to a JMS resource living in the server
from an application client (nor can a client access a server-side JDBC
pool; an app client can only remotely access EJBs running in the
server).

However, there is a trick whereby you essentailly configure the client
to independently connect to the same JMS server so it will still send
and receive messages using the same JMS topics/queues.  I believe what
you need to do in order to make this work is to add the kind of
settings that are in your connector deployment plan to your
geronimo-application-client.xml deployment plan, so the app client
also knows how to connect to the JMS server.  I don't have an example
of this, but I know there are some out there -- perhaps David J can
point you to one?

Thanks,
    Aaron

On 3/23/06, Marsha Johnson <ma...@jpsco.com> wrote:
> HI,
>
> I am using IBM Websphere Application Server Community Edition and I am trying
> to create a client application that will consume messages from a queue created
> from a deployment plan external to the application.  Both the queue and
> connection factory have been successfully deployed from the following plan:
>
> <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.0"
> configId="org/apache/geronimo/OPJmsPlan"
> parentId="geronimo/activemq/1.0/car">
> <resourceadapter>
> <resourceadapter-instance>
> <resourceadapter-name>OP JMS RA</resourceadapter-name>
> <config-property-setting name="ServerUrl">tcp://0.0.0.0:61616</config-property-
> setting>
> <config-property-setting name="UserName">geronimo</config-property-setting>
> <config-property-setting name="Password">geronimo</config-property-setting>
> <workmanager>
> <gbean-link>DefaultWorkManager</gbean-link>
> </workmanager>
> </resourceadapter-instance>
> <outbound-resourceadapter>
> <connection-definition>
> <connectionfactory-interface>javax.jms.ConnectionFactory</connectionfactory-
> interface>
> <connectiondefinition-instance>
> <name>jms/OPConnFactory1</name>
> <implemented-interface>javax.jms.QueueConnectionFactory</implemented-interface>
> <connectionmanager>
> <xa-transaction>
> <transaction-caching/>
> </xa-transaction>
> <single-pool>
> <max-size>10</max-size>
> <blocking-timeout-milliseconds>60000</blocking-timeout-milliseconds>
> <match-one/>
> </single-pool>
> </connectionmanager>
> </connectiondefinition-instance>
> </connection-definition>
> </outbound-resourceadapter>
> </resourceadapter>
> <adminobject>
>  <adminobject-interface>javax.jms.Queue</adminobject-interface>
> <adminobject-class>org.codehaus.activemq.message.ActiveMQQueue</adminobject-
> class>
>  <adminobject-instance>
>    <message-destination-name>jms/OPQueue</message-destination-name>
>    <config-property-setting name="PhysicalName">OPQueuePD</config-property-
> setting>
>  </adminobject-instance>
> </adminobject>
> </connector>
>
>
> My application-client.xml deployment plan has the following code:
>
> <resource-ref>
>  <res-ref-name>jms/OPConnFactory1</res-ref-name>
>  <res-type>javax.jms.QueueConnectionFactory</res-type>
>  <res-auth>Container</res-auth>
>  <res-sharing-scope>Shareable</res-sharing-scope>
> </resource-ref>
> <message-destination-ref>
>  <message-destination-ref-name>jms/OPQueue</message-destination-ref-name>
>  <message-destination-type>javax.jms.Queue</message-destination-type>
>  <message-destination-usage>Consumes</message-destination-usage>
>  <message-destination-link>jms/OPQueue</message-destination-link>
> </message-destination-ref>
>
> <message-destination>
>  <message-destination-name>jms/OPQueue</message-destination-name>
> </message-destination>
>
> My geronimo-application-client.xml deployment plan has the following code:
>
> <naming:resource-ref>
>   <naming:ref-name>jms/OPConnFactory1</naming:ref-name>
>   <naming:resource-link>jms/OPConnFactory1</naming:resource-link>
> </naming:resource-ref>
>
> However, when I try to deploy I get the following message:
> Error: Unable to distribute OPConsumer.ear: Unable to resolve
> resource reference 'jms/OPConnFactory1' (no matching resources
> found)
>
>
> What am I doing wrong?
>
>
>

Re: Accessing JMS resources from application client

Posted by David Jencks <da...@yahoo.com>.
On Mar 23, 2006, at 1:52 PM, Marsha Johnson wrote:

> HI,
>
> I am using IBM Websphere Application Server Community Edition and I  
> am trying
> to create a client application that will consume messages from a  
> queue created
> from a deployment plan external to the application.  Both the queue  
> and
> connection factory have been successfully deployed from the  
> following plan:
>
> <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/ 
> connector-1.0"
> configId="org/apache/geronimo/OPJmsPlan"
> parentId="geronimo/activemq/1.0/car">
> <resourceadapter>
> <resourceadapter-instance>
> <resourceadapter-name>OP JMS RA</resourceadapter-name>
> <config-property-setting name="ServerUrl">tcp://0.0.0.0:61616</ 
> config-property-
> setting>
> <config-property-setting name="UserName">geronimo</config-property- 
> setting>
> <config-property-setting name="Password">geronimo</config-property- 
> setting>
> <workmanager>
> <gbean-link>DefaultWorkManager</gbean-link>
> </workmanager>
> </resourceadapter-instance>
> <outbound-resourceadapter>
> <connection-definition>
> <connectionfactory-interface>javax.jms.ConnectionFactory</ 
> connectionfactory-
> interface>
> <connectiondefinition-instance>
> <name>jms/OPConnFactory1</name>
> <implemented-interface>javax.jms.QueueConnectionFactory</ 
> implemented-interface>
> <connectionmanager>
> <xa-transaction>
> <transaction-caching/>
> </xa-transaction>
> <single-pool>
> <max-size>10</max-size>
> <blocking-timeout-milliseconds>60000</blocking-timeout-milliseconds>
> <match-one/>
> </single-pool>
> </connectionmanager>
> </connectiondefinition-instance>
> </connection-definition>
> </outbound-resourceadapter>
> </resourceadapter>
> <adminobject>
>  <adminobject-interface>javax.jms.Queue</adminobject-interface>
> <adminobject-class>org.codehaus.activemq.message.ActiveMQQueue</ 
> adminobject-
> class>
>  <adminobject-instance>
>    <message-destination-name>jms/OPQueue</message-destination-name>
>    <config-property-setting name="PhysicalName">OPQueuePD</config- 
> property-
> setting>
>  </adminobject-instance>
> </adminobject>
> </connector>
>
>
> My application-client.xml deployment plan has the following code:
>
> <resource-ref>
>  <res-ref-name>jms/OPConnFactory1</res-ref-name>
>  <res-type>javax.jms.QueueConnectionFactory</res-type>
>  <res-auth>Container</res-auth>
>  <res-sharing-scope>Shareable</res-sharing-scope>
> </resource-ref>
> <message-destination-ref>
>  <message-destination-ref-name>jms/OPQueue</message-destination-ref- 
> name>
>  <message-destination-type>javax.jms.Queue</message-destination-type>
>  <message-destination-usage>Consumes</message-destination-usage>
>  <message-destination-link>jms/OPQueue</message-destination-link>
> </message-destination-ref>
>
> <message-destination>
>  <message-destination-name>jms/OPQueue</message-destination-name>
> </message-destination>
>
> My geronimo-application-client.xml deployment plan has the  
> following code:
>
> <naming:resource-ref>
>   <naming:ref-name>jms/OPConnFactory1</naming:ref-name>
>   <naming:resource-link>jms/OPConnFactory1</naming:resource-link>
> </naming:resource-ref>
>
> However, when I try to deploy I get the following message:
> Error: Unable to distribute OPConsumer.ear: Unable to resolve
> resource reference 'jms/OPConnFactory1' (no matching resources
> found)
>
>
> What am I doing wrong?

You need to deploy the jms connection factory and admin object you  
need to use on the app-client if the app client is going to use  
them.  (Presumably the server app uses them too, so they need to be  
where you already have them as well).  Here's an example of the  
syntax, extracted from the daytrader application that comes with  
geronimo:

     <module>
         <java>daytrader-streamer-${daytrader_version}.jar</java>
         <application-client  xmlns="http://geronimo.apache.org/xml/ 
ns/j2ee/application-client-1.0"
             configId="foo"
             clientConfigId="${pom.groupId}/${pom.artifactId}- 
streamer-client/${daytrader_version}/car">
             <resource>
                 <external-rar>activemq/activemq-ra/$ 
{activemq_version}/rar</external-rar>
                 <connector xmlns="http://geronimo.apache.org/xml/ns/ 
j2ee/connector"
            configId="org/apache/geronimo/SystemJMS"
            parentId="org/apache/geronimo/ActiveMQServer">
                     <resourceadapter>
                         <resourceadapter-instance>
                             <resourceadapter-name>ActiveMQ RA</ 
resourceadapter-name>
                             <config-property-setting  
name="ServerUrl">tcp://localhost:61616</config-property-setting>
                             <config-property-setting  
name="UserName">geronimo</config-property-setting>
                             <config-property-setting  
name="Password">geronimo</config-property-setting>
                             <workmanager>
                                 <gbean-link>DefaultWorkManager</ 
gbean-link>
                             </workmanager>
                         </resourceadapter-instance>
                         <outbound-resourceadapter>
                             <connection-definition>
                                 <connectionfactory- 
interface>javax.jms.ConnectionFactory</connectionfactory-interface>
                                 <connectiondefinition-instance>
                                     <name>jms/ 
TopicConnectionFactory</name>
                                     <implemented- 
interface>javax.jms.QueueConnectionFactory</implemented-interface>
                                     <implemented- 
interface>javax.jms.TopicConnectionFactory</implemented-interface>
                                     <connectionmanager>
                                         <xa-transaction>
                                             <transaction-caching/>
                                         </xa-transaction>
                                         <single-pool>
                                             <max-size>10</max-size>
                                             <blocking-timeout- 
milliseconds>5000</blocking-timeout-milliseconds>
                                             <match-one/>
                                         </single-pool>
                                     </connectionmanager>
                                 </connectiondefinition-instance>
                             </connection-definition>
                         </outbound-resourceadapter>
                     </resourceadapter>



                     <adminobject>
                         <adminobject-interface>javax.jms.Topic</ 
adminobject-interface>
                         <adminobject- 
class>org.codehaus.activemq.message.ActiveMQTopic</adminobject-class>
                         <adminobject-instance>
                             <message-destination- 
name>TradeStreamerTopic</message-destination-name>
                             <config-property-setting  
name="PhysicalName">TradeStreamerTopic</config-property-setting>
                         </adminobject-instance>
                     </adminobject>

                 </connector>
             </resource>
         </application-client>
     </module>


Unless you are using our packaging plugin to deploy your app you  
should be sure to eliminate any ${something_version} tags and replace  
them with the appropriate values.

thanks
david jencks

>
>