2 Replies Latest reply on Jul 30, 2015 7:37 AM by splitframe

    How to obtain JMSServerControl object

    splitframe

      I'm using an out of the box Wildfly 9 application server started with the standalone-full configuration.

      I want to create persistent topics at runtime, so the internet told me I need an instance of JMSServerControl.

      But I don't know how to get one.

      I read: https://developer.jboss.org/thread/166207 , but that didn't really help me.

      The doc says I can find the resource at jms.server but when I use:

      @Resource(mappedName = "jms.server") private JMSServerControl control; 

      it isn't found.

      I'm new to Wildfly, HornetQ and Dependency Injection so I'm a bit at a loss here.

        • 1. Re: How to obtain JMSServerControl object
          jbertram

          The JMSServerControl is an MBean and it cannot be injected.  You should ensure that JMX management is enabled on the HornetQ instance (e.g. <jmx-management-enabled>true</jmx-management-enabled>) and then you can look up the MBean from the platform's MBean server.  HornetQ ships with an example demonstrating how to do this from a remote client.  The example is named "jmx" and it's available in the HornetQ distribution.

           

          You could also use programmatic access to the Wildfly management interface and create topics that way.

          • 2. Re: How to obtain JMSServerControl object
            splitframe

            Hello Justin,

             

            thank you for your help.

             

            I now do it like this:

             

            MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();

            ObjectName oName = new ObjectName("org.hornetq:module=JMS,type=Server");

            JMSServerControl serverControl = MBeanServerInvocationHandler.newProxyInstance(mBeanServer, oName, JMSServerControl.class, false);

             

            Maybe it will help someone else aswell.