-
1. Re: createTopic Error!
jaikiran Oct 28, 2005 4:15 AM (in response to lovejesus)"lovejesus" wrote:
topic = session.createTopic("jms/MyTopic");
Instead, do the following:
topic = session.createTopic("topic/MyTopic");
-
2. Re: createTopic Error!
lovejesus Oct 28, 2005 5:20 AM (in response to lovejesus)
the same error still occurs.
i read the spec saying : better creating topic or queue using jmx-console than
programming, also i found a very complicated example to add a topic to the system.but is there any easy way to do this like
topic = session.createTopic("topic/MyTopic")
to create a new topic in jboss?
thanks. hope more guys could be involved in this discussion. -
3. Re: createTopic Error!
jaikiran Oct 28, 2005 6:07 AM (in response to lovejesus)Have you configured the topic in jboss? Something similar to:
<mbean code="org.jboss.mq.server.jmx.Topic" name="jboss.mq.destination:service=Topic,name=MyTopic"> <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends> </mbean>
have a look at jbossmq-destinations-service under server/default/jms for sample topic configuration -
4. Re: createTopic Error!
neotyk Oct 28, 2005 6:22 AM (in response to lovejesus)If you have MDB that listens on Queue/Topic that doesn't exist at deployment time,
Queue/Topic is created by JBoss. -
5. Re: createTopic Error!
jaikiran Oct 28, 2005 6:28 AM (in response to lovejesus)jmx-console is the best place to see whether your topic exists or not:
http://localhost:8080/jmx-console
Then under:
jboss.mq.destination
see if your topic is present -
6. Re: createTopic Error!
lovejesus Oct 28, 2005 7:04 AM (in response to lovejesus)If you have MDB that listens on Queue/Topic that doesn't exist at deployment time,Queue/Topic is created by JBoss.
this is exactly what i want!
for example , topic/MyTopic does'nt exist at the deploy time,so i want to create one topic named MyTopic at the run time.
but when the Queue/Topic already exists ,createTopic works well ! ( but i don't want to create an old one!),but when the name doesn't exist , error occurs.
how can i create a topic dynamically? -
7. Re: createTopic Error!
hargitt Oct 28, 2005 8:16 AM (in response to lovejesus)I implemented the following to be able to create dynamic queues. I am sure it can easily be adapted for a Topic:
/** * Gets the queue from JNDI. This is synchronized as if the queue does not * exist, a new queue is created. * @param iniCtx * @param destination * @return * @throws Exception */ public synchronized Queue getQueue(InitialContext iniCtx,String destination) throws Exception{ Queue queue=null; try { queue= (Queue)iniCtx.lookup(destination); } catch (NameNotFoundException e){ System.out.println("Queue "+destination+" does not exist."); } if (queue==null) queue=createQueue(iniCtx,destination); return queue; } /** * Creates a new queue using a JbossMQ (DestinationManagerMBean) only method, * thus breaking the JMS specifications. * @param iniCtx * @param destination * @return * @throws Exception */ private Queue createQueue(InitialContext iniCtx,String destination) throws Exception{ Queue queue=null; // Get the MBean server MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).iterator().next(); // Invoke the MBean server.invoke( new ObjectName("jboss.mq:service=DestinationManager"), "createQueue", new Object[] { destination, destination }, new String[] { String.class.getName(), String.class.getName()} ); queue=(Queue)iniCtx.lookup(destination); System.out.println("Queue "+destination+" has been created."); return queue; }
With JBossMQ, if you have messages in the queue and your system dies, the next time you startup and you create the queue dynamically like this, the messages are still there and you will start off from where you left off before you system crashed. -
8. Re: createTopic Error!
neotyk Oct 28, 2005 9:21 AM (in response to lovejesus)"lovejesus" wrote:
for example , topic/MyTopic does'nt exist at the deploy time,so i want to create one topic named MyTopic at the run time.
If it doesn't exist at deployment time it is created by JBossAS, not you."lovejesus" wrote:
but when the Queue/Topic already exists ,createTopic works well ! ( but i don't want to create an old one!),but when the name doesn't exist , error occurs.
Thats how createTopic should work.
I think you should read JMS spec.
I looks like you are missing the point of createTopic. -
9. Re: createTopic Error!
digbylock Oct 31, 2005 8:14 PM (in response to lovejesus)once a new topic is created programatically, does anyone know if it is possible to programatically deploy an MDB to subscribe to the new queue? Am trying to figure out a way of using MDB to subscribe to a topic which is not yet created at deploy time.
-
10. Re: createTopic Error!
neotyk Oct 31, 2005 8:28 PM (in response to lovejesus)"digbylock" wrote:
once a new topic is created programatically, does anyone know if it is possible to programatically deploy an MDB to subscribe to the new queue? Am trying to figure out a way of using MDB to subscribe to a topic which is not yet created at deploy time.
If at MDB deployment time no topic/queue, that mdb listens on, is present it is created automaticaly. -
11. Re: createTopic Error!
forumer Apr 6, 2007 10:07 PM (in response to lovejesus)I'd love to know how queues created dynamically, as shown by hargitt, can be used so I can put them to appropriate uses.
Can an MDB be made to listen to such a queue?
I understand that such a queue is longer lasting than a temporary queue.
Thanks