Method one is for vanilla JMS standalone clients.
Method two is in a J2EE enviroment, when doinf from inside a bean.
It is possible to do it the first way in beans to, but then you will not be part of the container transaction handling.
OK -thanks for your reply.
Now on to the next question.
In your example there are <resource-ref> elements
for both the topic connection factory AND the topic.
What would happen if you removed the resource-ref
entry for the topic (and let the bean get the topic
name from some other source)?
I have a setup where a stateless session bean should
write a message to a queue - but the name of the
queue is not known at deployment time so it is not
possible to create a resource-ref entry for it.
The bean is using container managed transactions.
At run time a servlet will call business methods on
the session bean - each business method has an
argument that identifies the queue to write to.
So I want to lookup the queue in the business method
using the jndi queue name from one of the business
method arguments and and write to it. Can I do this
and still get all that nice transactional support?
Should be doable. You have to be shure you get the destination from the same JNDI space as the connection.