On 1/23/07, Paul Moser <[EMAIL PROTECTED]> wrote:



James.Strachan wrote:
>
> On 1/23/07, Paul Moser <[EMAIL PROTECTED]> wrote:
>> I'm having problems looking up connection factories via JNDI, from a
>> standalone Java client when ActiveMQ is integrated with JBoss using a
>> RAR.
>
> ....
>
> Also the ActiveMQ Resource Adapter should not be used from a stand
> alone client - its only to be used inside a J2EE container (or MDP
> container like Jencks).
>
>

Sorry, I think I may have explained what I was trying to do badly. I've used
the ActiveMQ Resource Adapter to integrate ActiveMQ with JBoss so that my
MDBs use queues/topics actually on the embeded ActiveMQ broker rather than
JBossMQ/Messaging.

I also need to be able to submit/receive messages from one of the
queues/topics via a stand alone Java client, for this I've used standard
JMS/JNDI code, it knows nothing of the ActiveMQ RAR at all. It's the JNDI
lookup of the connection factory from this client to the J2EE server that
produces the strange result.

Yes - and thats what I was trying to explain but badly - don't use the
J2EE servers JNDI  for a stand alone client if you can help it. JMS is
not like EJB where you access resources remotely hosted in the J2EE
server - you should try use a stand alone client JNDI provider, like
Sun's file system or ActiveMQ's JNDI provider.


Unfortunately I don't have much control over
the clients, they are expecting to be able to find the connections
factories/topics/queues in the same JNDI tree as several EJB remote home
interfaces.

Damn


Are the connection factories/queues/topics just exposed by the RAR for use
within the J2EE server only.

Yes - as they are not using the regular JMS client API - they are
using J2EE RA stuff

You'll need to setup a regular JMS connection and any destination
objects you want in JNDI somewhere. Using JBoss's JNDI provider could
well work fine though - just make sure its actually normal JMS client
objects (ConnectionFactory & destinations) - and not RA stuff.  Also
make sure the J2EE server and your stand alone client are using the
exact same ActiveMQ jars since its gonna be using Java serialization
to transmit the Java objects in JNDI


To be completely honest, JNDI causes way more pain than its really
worth. You could get rid of all your JNDI pain by adding *one* line of
Java code to your application code...

ConnectionFactory factory = new ActiveMQConnectionFactory();

If you find a single line of code really offensive, then using Spring
is much much easier with way less configuration/deployment issues than
JNDI. But if you really wanna go ahead and use a remote JNDI provider
to configure the connection factory it should work - just make sure
you use the JMS API and not J2EE JCA/RA stuff

--

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

Reply via email to