-
1. Re: Dynamic Topic creation under JBoss6
ataylor Feb 3, 2012 8:34 AM (in response to marklevesque)JMSServerControl.createTopic(.....), see the management section in the user manual
-
2. Re: Dynamic Topic creation under JBoss6
marklevesque Feb 3, 2012 12:53 PM (in response to ataylor)Thanks Andy,
That's got me started in the right direction. But I'm kind of spinning my wheels on the management javadocs which seem to only describe abstract interfaces. Can you point me to a good starting point in the docs or a good example code listing?
Many thanks.
-
3. Re: Dynamic Topic creation under JBoss6
ataylor Feb 3, 2012 1:21 PM (in response to marklevesque)take a look at one of the management examples, just replace the control object with the one you want
-
4. Re: Dynamic Topic creation under JBoss6
marklevesque Feb 6, 2012 2:50 PM (in response to ataylor)Hi Andy,
I see "src/org/hornetq/jms/example/ManagementExample.java" which uses the management API to interface to the existing "exampleQueue" called out in "server0/hornetq-jms.xml", but I can't find any examples of using the management API to actually create a queue/topic dynamically. Is there an example of that in the hornetQ 2.2.5 examples?
Thanks,
Mark
-
5. Re: Dynamic Topic creation under JBoss6
ataylor Feb 7, 2012 5:17 AM (in response to marklevesque)Yes, you can just change that example to look up the JMSServerControl object instead of the queue and call which ever method you want. Saying that ive just noticed that you are using JBosss 7 which means you should probably use the AS7 Management API, take a look at https://github.com/jbossas/jboss-as/blob/master/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/embedded/demos/client/messaging/MessagingClientTestCase.java
-
6. Re: Dynamic Topic creation under JBoss6
tuxilla Mar 11, 2012 5:04 AM (in response to ataylor)The link is broken
-
7. Re: Dynamic Topic creation under JBoss6
marklevesque Mar 12, 2012 2:23 PM (in response to tuxilla)I was able to do what I wanted (create dynamic topic in Jboss6) by the following method:
// required inports
import javax.jms.QueueRequestor;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueConnection;
import org.hornetq.api.jms.HornetQJMSClient;
import org.hornetq.api.jms.management.JMSManagementHelper;
// dynamic topic creation code
String jndiName = "newTopic";
QueueConnectionFactory connectionFactory = (QueueConnectionFactory) jmsContext.lookup("/ConnectionFactory");
QueueConnection connection = connectionFactory.createQueueConnection();
Queue managementQueue = HornetQJMSClient.createQueue("hornetq.management");
QueueSession session = (QueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
connection.start();
Message m = session.createMessage();
JMSManagementHelper.putOperationInvocation(m, "jms.server", "createTopic", jndiName);
QueueRequestor requestor = new QueueRequestor(session, managementQueue);
Message reply = requestor.request(m);
logInfo("result of topic creation request for <" + jndiName + ">= " + JMSManagementHelper.hasOperationSucceeded(reply));
For this to work, you must allow the user running the code to have 'manage' privileges in "jboss-6.1.0.Final/server/default/deploy/hornetq/hornetq-configuration.xml".
Or you can do what I did as a temporary measure and just disable security as follows in "hornetq-configuration.xml":
<!-- Removed to allow creation of dynamic topics
<security-settings>
<security-setting match="#">
<permission type="createNonDurableQueue" roles="guest"/>
<permission type="deleteNonDurableQueue" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="send" roles="guest"/>
</security-setting>
</security-settings>
-->
<security-enabled>false</security-enabled>