5 Replies Latest reply on Aug 2, 2016 4:57 PM by jfisherdev

    JMS Destination Resource Registration Issues

    jfisherdev Novice

      I am writing an extension that will deploy a JMS topic whose name is based on the name of the application being deployed. For example, if an application called myApp.ear is deployed, a topic called "myAppTopic" would be deployed (the appropriate JNDI bindings would be created as well).


      I am targeting a standalone WildFly 9.0.2 server with HornetQ.

       

      Although the DeploymentUnitProcessor I am using to do this executes without any issues that halt the deployment process, I have encountered this issue:

       

      The management resource for the destination I would expect to see is not created. For example, using my original example and a hornetq server called "default" I would expect to find a management resource for the destination with this path address: /subsystem=messaging/hornetq-server=default/jms-topic=myAppTopic


      However, I do not find a management resource for the destination. It also does not appear in the management console as a destination.


      There do appear to be resources in the runtime-queue whose names are in this form: jms.(queue|topic).$destinationName$


      Also, I do see the JNDI bindings specified for the destinations deployed by this DeploymentUnitProcessor in the management console under Runtime/Subsystems/JNDI View.


      My DeploymentUnitProcessor implementation is modeled after the JMSTopicAdd handler and looks like this:


      public class DestinationDeploymentProcessor implements DeploymentUnitProcessor {
      
      public static final Phase PHASE = Phase.DEPENDENCIES;
      
      public static final int PRIORITY = 0x5200;
      
      @Override
      public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
      
           //Value is built from the deploymentUnit name, for example "myAppTopic"
           final String topicName = ...;
           final String[] jndiBindings = {"java:topic/" + topicName, ...}
           
           final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
           final ServiceName hornetQServiceName = MessagingServices.getHornetQServiceName(CommonAttributes.DEFAULT);
           // Comment copied from JMSTopicAdd:
           // Do not pass the JNDI bindings to HornetQ but install them directly instead so that the
           // dependencies from the BinderServices to the JMSQueueService are not broken.
           final JMSTopicService jmsTopicService = JMSTopicService.installService(topicName, hornetQServiceName, serviceTarget, new String[0]);
           final ServiceName jmsTopicServiceName = JMSServices.getJmsTopicBaseServiceName(hornetQServiceName).append(topicName);
           for(String jndiBinding : jndiBindings){
                // Comment copied from JMSTopicAdd:
               // install a binder service which depends on the JMS topic service
               BinderServiceUtil.installBinderService(serviceTarget, jndiBinding, jmsTopicService, jmsTopicServiceName);
           }
      }
      
      }
      

       

      Any information on how to solve this issue or even to let me know if this is possible or not would be appreciated.

        • 1. Re: JMS Destination Resource Registration Issues
          Miroslav Novak Master

          I'm not sure if this approach can work.

           

          There is official way how to setup JMS destinations during deployment which I'm not sure you tried.

           

          You can create hornetq-jms.xml with content like:

           

          <?xmlversion="1.0"encoding="UTF-8"?>
          <messaging-deployment xmlns="urn:jboss:messaging-deployment:1.0">
              <hornetq-server>
                  <jms-destinations>
                      <jms-queue name="QueueOne">
                          <entry name="java:jboss/exported/TestQueueOne"/>
                          <durable>true</durable>
                      </jms-queue>
                      <jms-topic name="TopicOne">
                          <entry name="java:jboss/exported/TestTopicOne"/>
                      </jms-topic>
                  </jms-destinations>
              </hornetq-server>
          </messaging-deployment>
          

          and add it to your deployment. It will create queue/topics per your needs.

          • 2. Re: JMS Destination Resource Registration Issues
            jfisherdev Novice

            I am aware of this approach.

             

            The documentation about -jms.xml files Messaging configuration - WildFly 9 - Project Documentation Editor does say that this approach is not recommended for production use. I want the destinations I am deploying to be available as management resources for management and monitoring purposes, and the -jms.xml file approach does not support this. In any case, the point of the DeploymentUnitProcessor shown in the original post is to dynamically deploy a destination using the deployment name for the destination name, which is different than using the -jms.xml approach.

             

            Mainly I am wondering what the difference is between what happens the Add operation handlers, which are executed to add each destination specified in the configuration on startup or when a destination is added via the CLI/Management API, and what I am trying to do in the DeploymentUnitProcessor.

            • 3. Re: JMS Destination Resource Registration Issues
              jfisherdev Novice

              Unless I am mistaken, I think the real issue is that model changes are inherently not possible during deployment, which is what I was trying to do here.

              • 4. Re: JMS Destination Resource Registration Issues
                Tomaz Cerar Master

                jfisherdev wrote:

                The management resource for the destination I would expect to see is not created. For example, using my original example and a hornetq server called "default" I would expect to find a management resource for the destination with this path address: /subsystem=messaging/hornetq-server=default/jms-topic=myAppTopic


                However, I do not find a management resource for the destination. It also does not appear in the management console as a destination.

                This is expected, as only queues/topics that are registered in subsystem itself (standalone.xml) get registered under subsystem=mesaging.

                the deployment ones, get registered under /deployment=<name-of-deployment>/subsystem=messaging/...

                 

                jfisherdev wrote:


                There do appear to be resources in the runtime-queue whose names are in this form: jms.(queue|topic).$destinationName$


                Also, I do see the JNDI bindings specified for the destinations deployed by this DeploymentUnitProcessor in the management console under Runtime/Subsystems/JNDI View.


                My DeploymentUnitProcessor implementation is modeled after the JMSTopicAdd handler and looks like this:


                1. public class DestinationDeploymentProcessor implements DeploymentUnitProcessor { 
                2.  
                3. public static final Phase PHASE = Phase.DEPENDENCIES; 
                4.  
                5. public static final int PRIORITY = 0x5200
                6.  
                7. @Override 
                8. public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { 
                9.  
                10.      //Value is built from the deploymentUnit name, for example "myAppTopic" 
                11.      final String topicName = ...; 
                12.      final String[] jndiBindings = {"java:topic/" + topicName, ...} 
                13.       
                14.      final ServiceTarget serviceTarget = phaseContext.getServiceTarget(); 
                15.      final ServiceName hornetQServiceName = MessagingServices.getHornetQServiceName(CommonAttributes.DEFAULT); 
                16.      // Comment copied from JMSTopicAdd: 
                17.      // Do not pass the JNDI bindings to HornetQ but install them directly instead so that the 
                18.      // dependencies from the BinderServices to the JMSQueueService are not broken. 
                19.      final JMSTopicService jmsTopicService = JMSTopicService.installService(topicName, hornetQServiceName, serviceTarget, new String[0]); 
                20.      final ServiceName jmsTopicServiceName = JMSServices.getJmsTopicBaseServiceName(hornetQServiceName).append(topicName); 
                21.      for(String jndiBinding : jndiBindings){ 
                22.           // Comment copied from JMSTopicAdd: 
                23.          // install a binder service which depends on the JMS topic service 
                24.          BinderServiceUtil.installBinderService(serviceTarget, jndiBinding, jmsTopicService, jmsTopicServiceName); 
                25.      } 
                26.  

                 

                Any information on how to solve this issue or even to let me know if this is possible or not would be appreciated.

                look under /deployment=... resource

                • 5. Re: JMS Destination Resource Registration Issues
                  jfisherdev Novice

                  That makes sense. Looking back at this discussion we had about doing something similar with data sources, Re: WildFly 9.0.2 MBean Start Method Timeout/Deadlock, I am guessing that this is another situation where I am trying to add management resources during deployment. Since the management model cannot be modified during deployment, these destinations deployed as part of the deployment process will not be managed JMS destinations.

                   

                  Thank you for clarifying this.