14 Replies Latest reply on Sep 9, 2003 12:57 PM by Adrian Brock

    Queue creation at runtime

    anithavs Newbie

      Hello
      I would like to know is it possible to create queues dynamically in jboss-3.2.1_tomcat-4.1.24. My requirement is queues 've to be generated on the fly as and when required.
      All help is appreciated
      Thanks
      Anitha

        • 1. Re: Queue creation at runtime
          Adrian Brock Master

          If temporary queues are no use, use the DestinationManager
          see http://localhost:8080/jmx-console

          And before you ask, you use the MBeanServer programatically.

          Regards,
          Adrian

          • 2. Re: Queue creation at runtime
            anithavs Newbie

            Hi,
            Thanx for the quick reply.
            But i want to create the queues programmatically. So, i would not be going thru the destination manager.
            So, can u elaborate on how i can use the temporary queues b'cuz i am getting the "This destination does not exist" while creating a temporay queue.
            And also is it possible to do the same with MBeans?I would not be creating the queues on jboss startup but sometime later.
            So, which is a better option i should adopt?
            Thanks
            Anitha

            • 3. Re: Queue creation at runtime
              Adrian Brock Master

              temporary queues are part of the JMS spec.
              They only last for the duration of the connection that created them.

              If you want something more permenant use the
              DestinationManager mbean's createQueue operation.
              It won't survive a shutdown.

              Regards,
              Adrian

              • 4. Re: Queue creation at runtime
                arabin Novice

                I have several questions here.
                1. There are two separate methods createQueue. One of them has 1 String argument, another one has 2 String arguments.
                What do those arguments mean?

                For instance, in order to create a queue that would be defined in jbossmq-destinations-service.xml as

                <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager


                do I need to put the first argument "org.jboss.mq.server.jmx.Queue" and the second argument "jboss.mq.destination:service=Queue,name=E" ?

                I tried that - the Queue is not added to jboss.mq.destination section of http://localhost:8080/jmx-console/

                Any ideas?

                2. What if I need to create a really permanent Queue, that WILL survive shutdown? Is that actually possible?

                • 5. Re: Queue creation at runtime
                  Adrian Brock Master

                  The two argument version lets you override the jndi name
                  default queue/<first parameter>
                  The first argument is the queue name.
                  http://esprit.ccs.yorku.ca/jboss/302/javadocs/messaging/org/jboss/mq/server/jmx/DestinationManager.html

                  To make it survivea reboot you need something to create
                  the queue at boot time, e.g. putting an xml file in deploy.

                  Regards,
                  Adrian

                  • 6. Re: Queue creation at runtime
                    arabin Novice

                    Is there any tool in JBoss that allows to rewrite the xml file to create an entry there?
                    If I use DestinationManager AND at the same time (or immediately after that) change the xml file to include the entry for the queue or topic, I guess that will make the change permanent?

                    • 7. Re: Queue creation at runtime
                      Adrian Brock Master

                      You don't need to use the DestinationManager if you are
                      adding an xml file to deploy (the normal deployment process
                      will do it).

                      I would suggest creating one file per queue, otherwise you
                      will redeploy every destination when you create a new queue.

                      You can get the deploy directory from the system properties
                      either directly or from the ServerInfo mbean.

                      Regards,
                      Adrian

                      • 8. Re: Queue creation at runtime
                        arabin Novice

                         

                        You don't need to use the DestinationManager if you are
                        adding an xml file to deploy (the normal deployment process
                        will do it).


                        You mean as soon the file changes, the queue is created automatically, without restarting JBoss?

                        I would suggest creating one file per queue, otherwise you
                        will redeploy every destination when you create a new queue.


                        I thought all queues are in jboss-destination-service.xml Isn't it correct? What are the requirements to file name?

                        You can get the deploy directory from the system properties
                        either directly or from the ServerInfo mbean.

                        I do not quite understand you.
                        Do you mean I can create several various directories and have jboss-destination-service.xml file in each? So, the file name will be the same, but the contents will be different (one queue per file)?

                        Regards,
                        Adrian

                        • 9. Re: Queue creation at runtime
                          Adrian Brock Master

                          You can deploy the queues in any file that ends with
                          -service.xml
                          You can also include a -service.xml in your ejb-jar.xml
                          if you want to deploy a queue for a specific application.

                          Changing a -service.xml will cause the queue to be undeployed
                          then redeployed (assuming the queue is still in the file).
                          If you have 10 destinations in one file all of them will be
                          redeployed when you might just want to change one.

                          For the directory, I mean you might want to use the system
                          property or the value from the ServerInfo mbean rather than
                          hardwiring "server/default/deploy" which might move or
                          change name, e.g. "server/all/deploy"

                          Regards,
                          Adrian

                          • 10. Re: Queue creation at runtime
                            Adrian Brock Master

                            That should read you can include a -service.xml in
                            your ejb jar (put it in the root of the archive)

                            Regards,
                            Adrian

                            • 11. Re: Queue creation at runtime
                              arabin Novice

                              Can I have an example of ejb-jar.xml, containing service.xml file? It looks like I cannot find an example.
                              ejb-jar.xml files I can see do not have service-xml included.
                              Thanks

                              • 12. Re: Queue creation at runtime
                                Adrian Brock Master

                                Did you read my clarification?

                                myejbs.jar/META-INF/ejb-jar.xml
                                myejbs.jar/myqueue-service.xml
                                myejbs.jar/com/whatever/classes/etc

                                Regards,
                                Adrian

                                • 13. Re: Queue creation at runtime
                                  arabin Novice

                                  Just to make sure I understand you in a right way.

                                  In the configuration

                                  myejbs.jar/META-INF/ejb-jar.xml
                                  myejbs.jar/myqueue-service.xml
                                  myejbs.jar/com/whatever/classes/etc

                                  the file ejb-jar.xml itself does not contain any reference to myqueue-service.xml. The only way how JBoss knows that the queues are defined in myqueue-service.xml is the myqueue-service.xml is THE ONLY .xml file in the root directory of myejbs.jar.
                                  Right?

                                  Then upon adding a new (or just adding, if there was none before) .xml file into the root, new queues are automatically deployed. Or by modifying an .xml file, the queues are automatically redeployed.

                                  Is my understanding correct?

                                  • 14. Re: Queue creation at runtime
                                    Adrian Brock Master

                                    This is using "russian-doll" packaging. You place other
                                    deployments inside an ejb jar. As many as you like as
                                    long as they end with a known ending e.g. -service.xml

                                    They only redeploy with the top level package.

                                    I'm assuming you want to create a queue for application?

                                    Regards,
                                    Adrian