1

I have an swing based application with is communicating with wildfly 10. The application creates queue/topic dynamically. I cant restart the wildfly each time the queue/topic get created. I want to instantiate JMS queue/topic and use it without restarting the server.

Sandeep
  • 21
  • 1
  • 4

3 Answers3

1

You can connect to the wildfly server via it's management port (9999 by default) and use it's cli to add the queues.

There's a java api with wich you can issue the jms-queue:add command - https://docs.jboss.org/author/display/WFLY10/The+native+management+API

And the commands that you should execute to create the jms/topics are as follows:

/subsystem=messaging-activemq/server=default/jms-queue=queueName:add(entries=["java:/jms/queue/queueName"])
/subsystem=messaging-activemq/server=default/jms-topic=topicName:add(entries=["java:/jms/topic/topicName"])

You can also use cli to add the address and security settings for all queues. Check out this answer for a relatively full list of commands that can be executed for the messaging subsystem - How to set up messaging subsystem using CLI in Wildfly

metodski
  • 546
  • 8
  • 16
  • Thanks for the answer, but this way the queue/topic will get created in standalone*.xml and to use this queue/topic, the server has to be restarted – Sandeep May 31 '17 at 10:03
  • Are you sure? We have similar logic in place and adding/removing queues and topics doesn't require a server reload. The only thing that requires restart is adding the whole messaging subsystem to the standalone.xml. – metodski May 31 '17 at 10:45
  • I was tried the above code and the queue/topic is getting created in standalone.xml but the application is not picking the queue until the sever restart. It keep throws javax.naming.nameNotFoundException and it is getting resolved after restarting the server. As per my understanding the changes making in standalone.xml require a server restart to reflect the changes – Sandeep Jun 01 '17 at 11:43
  • Changes in standalone.xml don't exactly dictate a server restart. Only some do, like adding the messaging extension or the messaging subsystem on it's own. This is the approach we used and – metodski Apr 16 '18 at 13:16
1

I figured out a way to resolve this problem. I have created an xml file FileName-jms.xml and started appending new queue/topic under tag

<?xml version="1.0" encoding="UTF-8"?><messaging-deployment xmlns="urn:jboss:messaging-activemq-deployment:1.0">
   <server name="default">
      <jms-destinations>
        <jms-topic name="topic/response">
            <entry name="java:/jms/topic/response"/>
            <entry name="java:jboss/exported/jms/topic/response"/>
        </jms-topic>
        <jms-queue name="queue/request">
            <entry name="java:/jms/queue/request"/>
            <entry name="java:jboss/exported/jms/queue/request"/>
        </jms-queue>
      </jms-destinations>
   </server>
</messaging-deployment>

Deploy this under deployments folder and wildfly will deploy this along with other files. By using simple java code, the file can be access and modify. Once it is modified the server redeploy the same.

Please go though the documentation for more details https://docs.jboss.org/author/display/WFLY8/Messaging+configuration

Sandeep
  • 21
  • 1
  • 4
0

Look at https://wildscribe.github.io/WildFly/14.0/subsystem/messaging-activemq/server/address-setting/index.html

You can set the auto-create-queue option to true,

But as mentioned, just because you can, really doesn't mean you should :)

Marc Magon
  • 713
  • 7
  • 11