dynamic creation of ObjectStore destinations
Please Help!
I am obviously missing something!
I am dynamically creating queues with myDQueue = new com.sun.messaging.Queue(dest);
This works fine:
I can see them apear in the admin console unser the brokers/MyBroker/Destinations node.;
I can send messages to them, recieve from them, Attach listenrs to them.
What I cannot do is look them up with:
Queue myQueue = (javax.jms.Queue)ctx.lookup(dest);
This seems to lookup destination in the ObjectStores/MyObjectStore/Destinations node.
If I manually create object store destination and then dynamically create queues then things work OK but I want to avoid the manual step in the console.
This is probably really obvious to someone who knows what they are doing!
[789 byte] By [
ajw1967] at [2007-11-13]

Hi,
Short answer: there is no way to skip the manual
administrator step of creating object stores and populating them.
You usually do one of the following (not both):
a. Create destinations from within your app via:
myDQueue = new com.sun.messaging.Queue(dest);
b. Look up destinations via JNDI, after populating
the relevant object stores.
Long answer:
There are destinations on the broker where your JMS
messages actually go; (also called physical destinations)
and there are destination administered objects which are
stored in JNDI repositories and are looked up by JMS apps
via JNDI.
Creating and using a destination via:
myDQueue = new com.sun.messaging.Queue(dest);
will 'autocreate' the destination in the broker. Any JMS
application can do this as long as the broker does not
have the following properties set to false (by default
they are set to true):
imq.autocreate.topic
imq.autocreate.queue
This is a quick way for folks to get started with writing
and running JMS apps - no additional administrator tasks
needed.
Note that auto-creating a destination like above (or
even administratively creating destinations on the broker via
imqcmd) has no impact on destination administered objects in
any JNDI repository. They are distinct and separate.
In a deployment scenario, it might not be feasible to have the
destinations in the broker be auto-created, which basically gives
any JMS app the ability to create any destination at will. It is
better to have the broker's resources controlled by the
broker and not the app. In this case, the administrator will
set:
imq.autocreate.topic=false
imq.autocreate.queue=false
which will force JMS applications to lookup their destination
administered objects via:
Queue myQueue = (javax.jms.Queue)ctx.lookup(dest);
instead of creating them (since it will be disallowed with
the setting of the above 2 config properties). The destination
administered objects are merely objects that tell the JMS
runtime which destinations to send/receive messages to/from.
To make this JNDI lookup code work, the administrator needs to:
- create a JNDI object store, whether it is file or LDAP based
- create/store the relevant destination/connection factory
administered objects in the object store
- make the location of these objects known to the JMS apps. This
is usually in the form of JNDI properties like:
java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
java.naming.provider.url=ldap://foo.com:389/ou=mqobjs, o=myapp
etc.
More details on object stores and administered objects at our
online admin guide:
Chapter 7 Managing Administered Objects
http://docs.sun.com/source/817-6024/adminobj.html
hope this helps,
-isa
http://www.sun.com/software/products/message_queue/