Howto auto-create a destination from a Java client ?
It seems that one cannot auto-create a destination by looking up a JNDI name that is not existing, as it throws a JNDI "Name not found" exception.
Queue myQueue = (Queue)ctx.lookup("SampleQueue");
The only way to create an auto-created destination is by directly instantiating one of Sun's classes:
Queue myQueue=new com.sun.messaging.Queue("AutoCreatedSampleQueue");
... but the code will not be portable. Is there a way to auto-create destinations and still have the code portable across different JMS implementations ? ( e.g. ActiveMQ allows you to do this by adding the "dynamic" prefix on the JNDI name )
[724 byte] By [
j.salvo] at [2007-11-26 8:16:11]

# 1
You can use the standard JMS Session API available to create a Queue or Topic identity object.
i.e. Queue _myQueue = _session.createQueue("xxxxxxxxxxxxxx");
Note that while this is a portable API, the syntax of the name parameter may not be portable across providers.
Further, this only creates the Destination identity object and not the physical Destination object.
For Sun MQ, when this identity object is used to create a producer or consumer, the physical destination is 'auto-created' if the broker is operating with factory defaults.
Other providers may not support the 'auto-creation' facility or even if supported, it may be turned off by the administrator, in which case the application needs to handle those cases to be a provider-independant JMS application.