-
1. Re: Programmaticaly create queue
coyotesqrl Sep 19, 2006 11:49 AM (in response to pascallambert)One solution you might consider is creating a single queue to handle all the traffic of this dynamic type, then using metadata to distinguish one recipient from another. In this way, you configure a single real queue on the server, but have an infinite number of virtual queues.
For extremely high load, this is suboptimal, but for moderate volume should perform with roughly the same characteristics as a dynamic queue solution. -
2. Re: Programmaticaly create queue
ovidiu.feodorov Sep 20, 2006 10:56 PM (in response to pascallambert)You can create a queue programmatically by invoking the "createQueue" JMX method on the ServerPeer MBean. Upon the method completion, your new queue will be accessible in JNDI and also through the JMX interface, similarly to any regular ("deployed") queue.
The queue is handled like any other regular queue, so if the server crashes, the queue's state can be recovered from the database, but your program will have to somehow remember that it created the queue dynamically, and re-create it programmatically after recovery. The messaging server doesn't handle this for you. It is, however, something relatively simply to implement at application level.
To see an example of how this works, take a look at DestinationManagerTest.testCreateQueueProgramatically() -
3. Re: Programmaticaly create queue
vakuthota Dec 28, 2006 1:10 PM (in response to pascallambert)Do i need to migrate to JBoss Messaging from JBoss MQ to create the queues programatically ??
-
4. Re: Programmaticaly create queue
ovidiu.feodorov Dec 28, 2006 9:25 PM (in response to pascallambert)JBossMQ can also create queues programatically.
-
5. Re: Programmaticaly create queue
liudan2005 Jan 4, 2007 12:29 PM (in response to pascallambert)Why do I get InstanceNotFoundException ? here is my code:
mbeanServer = MBeanServerFactory.createMBeanServer(); ObjectName objName = new ObjectName("jboss.messaging:service=ServerPeer"); mbeanServer.invoke(objName, "createQueue", new Object[] { "anyname", null }, new String[] { "java.lang.String", "java.lang.String"} );
-
6. Re: Programmaticaly create queue
ovidiu.feodorov Jan 27, 2007 11:03 PM (in response to pascallambert)I don't know.
Do your run that code from within the server VM?
Did you start the Messaging server?
Do you see the MBean in the jmx console? -
7. Re: Programmaticaly create queue
schnelzer Mar 14, 2007 5:04 PM (in response to pascallambert)So what is the best way to receive messages in the server if a queue is created programmatically? An MDB destination is set at deployment. Should I start a Runnable consumer on the server?
-
8. Re: Programmaticaly create queue
apk2072 Mar 26, 2007 4:30 PM (in response to pascallambert)I also have the same requirement in creating the Queues programatically instead of maintaining the JBoss deploy folder.
I maintain my queue name in one of my configuration table, while starting up the server reads these queue names and deploys using following code.
MBeanServerConnection mBeanServer = lookupMBeanServerProxy();
ObjectName serverObjectName = new ObjectName("jboss.messaging:service=ServerPeer");
String queueName = jndiName.substring(jndiName.lastIndexOf('/') + 1);
mBeanServer.invoke(serverObjectName, "deployQueue", new Object[] {
queueName, jndiName }, new String[] { "java.lang.String","java.lang.String" });
REMEMBER, 1.2 HAS A SMALL BUG OVER 1.1. IT IS NO LONGER A "createQueue", IT IS "deployQueue".
-APK -
9. Re: Programmaticaly create queue
thangle Feb 2, 2008 11:39 PM (in response to pascallambert)I have some questions relating this topic:
1. How many Queues can we safely create dynamically under JBoss 4.0.3? Is it a recommended way?
2. What is default persistence of Queues created in this way? Can we set persistent method for these Queues?
3. What API can we use to remove Queues dynamically? Does it clean up all related data of this Queue in database (presume that we can set JDBC persistent model for dynamic created Queues)?
Thanks a lot in advance -
10. Re: Programmaticaly create queue
timfox Feb 3, 2008 9:39 AM (in response to pascallambert)"thangle" wrote:
I have some questions relating this topic:
1. How many Queues can we safely create dynamically under JBoss 4.0.3? Is it a recommended way?
JBoss 4.0.3 doesn't use JBossMessaging, it uses JBoss MQ. Please post in the JBoss MQ forum, this the JBoss Messaging forum :) -
11. Re: Programmaticaly create queue
poonamagarwal Nov 20, 2008 7:09 AM (in response to pascallambert)I was able to create queues using deployQueue from the JMX Web console....but when I code it.....
I get InstanceNotFoundException (bean not registered) when I use the following code
mbeanServer = MBeanServerFactory.createMBeanServer();
ObjectName objName = new ObjectName("jboss.messaging:service=ServerPeer");
mbeanServer.invoke(objName, "deployQueue",
new Object[] { "anyname", null },
new String[] { "java.lang.String", "java.lang.String"} );
I am running the above code from a EJB Session bean in the same jboss server.
I have done all the steps to replace a Jboss MQ instance to a JBM 1.4 in jboss 4.2.0.
I have started the messaging server as I am able to perform this operation from jmx-web console...
Can somebody help?
-Poonam -
12. Re: Programmaticaly create queue
ataylor Nov 20, 2008 7:40 AM (in response to pascallambert)You need to look up the mbean server not create one.
-
13. Re: Programmaticaly create queue
poonamagarwal Nov 20, 2008 8:42 AM (in response to pascallambert)Thanks
I could achieve the same by looking up the
jmx/rmi/RMIAdaptor and then fire invoke() on it.
I am now able to createQueue dynamically using this.