-
2. Re: Create queues and topics at run-time
st.bolli Sep 23, 2010 4:15 AM (in response to clebert.suconic)1 of 1 people found this helpfulOk, the docs link work correctly writing the followng example...
public class CreateRuntimeQueueJMS1 { private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi"; public static void main(String[] args) throws Throwable { System.out.println("Start."); JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap()); MBeanServerConnection mbsc = connector.getMBeanServerConnection(); ObjectName name=new ObjectName("org.hornetq:module=JMS,type=Server"); JMSServerControl control = (JMSServerControl)MBeanServerInvocationHandler.newProxyInstance(mbsc,name,JMSServerControl.class,false); control.createQueue("testQ1","queue/testQ1"); System.out.println("End."); } }
...but in this way it is necessary to enable the JMX Console remote management adding the following option to JVM_OPT
set "JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
In my deployment environment the JMX console is disable and cannot be activated for security reason (neither considering ssl and authentication).
Is there another way to create and bind to JNDI a new queue at run-time without using the JMX?
Thanks!
-
3. Re: Create queues and topics at run-time
jmesnil Sep 23, 2010 4:37 AM (in response to st.bolli)Stefano Bolli wrote:
Is there another way to create and bind to JNDI a new queue at run-time without using the JMX?
You can use JMS to send management messages: http://hornetq.sourceforge.net/docs/hornetq-2.1.2.Final/user-manual/en/html/management.html#management.jms
HornetQ comes with a "management" example which illustrate this.
-
4. Re: Create queues and topics at run-time
st.bolli Sep 23, 2010 5:20 AM (in response to jmesnil)Ok, the queue is correctly created, but qhen I restart the JBoss server it is not binded in JNDI.
The same problem is presented here:
Do you have any suggestion about this issue?
Thanks !
-
5. Re: Create queues and topics at run-time
jmesnil Sep 23, 2010 5:28 AM (in response to st.bolli)Stefano Bolli wrote:
Ok, the queue is correctly created, but qhen I restart the JBoss server it is not binded in JNDI.
The same problem is presented here:
Do you have any suggestion about this issue?
Thanks !
this bug's been fixed: http://community.jboss.org/message/561152#561152
-
6. Re: Create queues and topics at run-time
lukhash Feb 5, 2013 7:04 AM (in response to st.bolli)Hi
I want to use HornetQ 2.2.13 on JBoss AS 7.1.1 and a don't know how can I create topics dynamically.
I found many solution to older version HornetQ and JBoss but it's dont work with HornetQ 2.2.13.
Can anyone write a simple method to create topics at runtime?
Thanks!!!
-
7. Re: Create queues and topics at run-time
ataylor Feb 5, 2013 8:40 AM (in response to lukhash)Hi
I want to use HornetQ 2.2.13 on JBoss AS 7.1.1 and a don't know how can I create topics dynamically.
I found many solution to older version HornetQ and JBoss but it's dont work with HornetQ 2.2.13.
Can anyone write a simple method to create topics at runtime?
Thanks!!!
you need to use the AS7 CLI (command line interface), take a look at teh AS7 docs.
-
8. Re: Create queues and topics at run-time
lukhash Feb 5, 2013 9:43 AM (in response to ataylor)Thanks for quick response
yes, I can use CLI but I want create topic programmatically from my web application
-
9. Re: Create queues and topics at run-time
ataylor Feb 5, 2013 10:13 AM (in response to lukhash)as far as i am aware you can call the CLI programmatically from a servlet. There would be more in the AS7 docs, its not really a HornetQ question.
-
10. Re: Create queues and topics at run-time
jbertram Feb 5, 2013 12:38 PM (in response to lukhash)Here's a simple example of how to create a JMS queue via the JBoss AS7 CLI programmatically:
import org.jboss.as.controller.client.ModelControllerClient; import org.jboss.as.controller.client.helpers.ClientConstants; import org.jboss.dmr.ModelNode; import java.net.InetAddress; public class ManagementExample { public static void main(final String[] args) throws Exception { ModelControllerClient client = null; ModelNode op = new ModelNode(); ModelNode address = op.get(ClientConstants.OP_ADDR); address.add("subsystem", "messaging"); address.add("hornetq-server", "default"); // the name of the queue String queue = "myQueue"; address.add("jms-queue", queue); // the JNDI entries ModelNode entries = op.get("entries"); entries.add("jms/queue/" + queue); entries.add("jboss/exported/jms/queue/" + queue); op.get(ClientConstants.OP).set(ClientConstants.ADD); try { client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9999); ModelNode result = client.execute(op); System.out.println(result); } finally { if (client != null) { try { client.close(); } catch (Exception e) { // no-op } } } } }