1 2 Previous Next 15 Replies Latest reply on May 24, 2010 6:50 AM by jaikiran pai

    JMS in JBoss AS 6.0.0.M3

    Frank Cornelis Newbie

      Since the JMS provider changed in JBoss AS 6.0.0.M3 to HornetQ, my messages no longer are delivered to the MDB when using an XA MySQL DefaultDS datasource. Everything works as expected when using the embedded HSQLDB. The JMS did work on JBoss AS 6.0.0.M2 when using a (local-tx) MySQL datasource. What should be configured to make the HornetQ JMS provider to work with an XA MySQL datasource?

       

      I send to the JMS queue via the regular code as follows:

      QueueConnection queueConnection = this.queueConnectionFactory
                      .createQueueConnection();
              try {
                  QueueSession queueSession = queueConnection.createQueueSession(
                          true, Session.AUTO_ACKNOWLEDGE);
                  try {
                      HarvestMessage harvestMessage = new HarvestMessage(issuerName,
                              false);
                      QueueSender queueSender = queueSession.createSender(this.queue);
                      try {
                          queueSender
                                  .send(harvestMessage.getJMSMessage(queueSession));
                      } finally {
                          queueSender.close();
                      }
                  } finally {
                      queueSession.close();
                  }
              } finally {
                  queueConnection.close();
              }

       

      Where queueConnectionFactory is defined as:

      @Resource(mappedName = "java:JmsXA")
      private QueueConnectionFactory queueConnectionFactory;

       

      And the queue as:

      @Resource(mappedName = HarvesterMDB.HARVESTER_QUEUE_NAME)
      private Queue queue;

       

      The MDB has the following annotations:

      @MessageDriven(activationConfig = {
              @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
              @ActivationConfigProperty(propertyName = "destination", propertyValue = HarvesterMDB.HARVESTER_QUEUE_NAME) })

       

      With the queue name:

      public static final String HARVESTER_QUEUE_NAME = "queue/trust/harvester";

       

      Further I have a hornetq-jms.xml in my SAR META-INF directory containing:

      <?xml version="1.0" encoding="UTF-8"?>
      <configuration xmlns="urn:hornetq"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
          <queue name="TrustServiceHarvester">
              <entry name="/queue/trust/harvester" />
          </queue>
      </configuration>

       

      This configuration works with the default HSQLDB datasource, but when switching to the XA MySQL datasource (see below for the config) the messages are no longer delivered.

      <datasources>
        <xa-datasource>
          <jndi-name>DefaultDS</jndi-name>
          <track-connection-by-tx>true</track-connection-by-tx>
          <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
          <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
          <xa-datasource-property name="DatabaseName">trust</xa-datasource-property>
          <xa-datasource-property name="User">trust</xa-datasource-property>
          <xa-datasource-property name="Password">some-password</xa-datasource-property>

          <metadata>
             <type-mapping>mySQL</type-mapping>
          </metadata>
        </xa-datasource>
      </datasources>

        • 1. Re: JMS in JBoss AS 6.0.0.M3
          jaikiran pai Master

          Frank Cornelis wrote:

           


           

          This configuration works with the default HSQLDB datasource, but when switching to the XA MySQL datasource (see below for the config) the messages are no longer delivered.

           

           

          HornetQ doesn't use any DB (it uses its own journal). So I am not sure how the datasource makes a difference. What exactly did you change?

          • 2. Re: JMS in JBoss AS 6.0.0.M3
            Frank Cornelis Newbie

            jaikiran pai wrote:

             

            Frank Cornelis wrote:

             


             

            This configuration works with the default HSQLDB datasource, but when switching to the XA MySQL datasource (see below for the config) the messages are no longer delivered.

             

             

            HornetQ doesn't use any DB (it uses its own journal). So I am not sure how the datasource makes a difference. What exactly did you change?

             

            I noticed that HornetQ indeed does not use the DefaultDS but its own journal. Hence the change from a local-tx MySQL datasource to an XA MySQL datasource. The configuration is listed below:

             

            <datasources>
              <xa-datasource>
                <jndi-name>DefaultDS</jndi-name>
                <track-connection-by-tx>true</track-connection-by-tx>
                <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
                <xa-datasource-property name="DatabaseName">trust</xa-datasource-property>
                <xa-datasource-property name="User">trust</xa-datasource-property>
                <xa-datasource-property name="Password">some-password</xa-datasource-property>
                <metadata>
                   <type-mapping>mySQL</type-mapping>
                </metadata>
              </xa-datasource>
            </datasources>

             

            But despite this, and the fact that HornetQ uses XA per default AFAIK, the messages are not delivered to the MDB.

            • 3. Re: JMS in JBoss AS 6.0.0.M3
              jaikiran pai Master

              Frank Cornelis wrote:

               


              I noticed that HornetQ indeed does not use the DefaultDS but its own journal. Hence the change from a local-tx MySQL datasource to an XA MySQL datasource. The configuration is listed below:

               

              Well, my point was that you don't have to do any changes to the DefaultDS configurations, since it doesn't come into picture (unless your application is using DefaultDS).

               

              Frank Cornelis wrote:

               

              But despite this, and the fact that HornetQ uses XA per default AFAIK, the messages are not delivered to the MDB.

               

              From the jmx-console (there's MBean for your queue), do you see whether the message are present in the queue to which you are sending the messages?

              • 4. Re: JMS in JBoss AS 6.0.0.M3
                jaikiran pai Master
                QueueSession queueSession = queueConnection.createQueueSession(  true, Session.AUTO_ACKNOWLEDGE);

                You are creating a transacted session? Try this and see if this works:

                 

                 

                QueueSession queueSession = queueConnection.createQueueSession( false, Session.AUTO_ACKNOWLEDGE);
                • 5. Re: JMS in JBoss AS 6.0.0.M3
                  Frank Cornelis Newbie

                  jaikiran pai wrote:

                   

                  Frank Cornelis wrote:

                   


                  I noticed that HornetQ indeed does not use the DefaultDS but its own journal. Hence the change from a local-tx MySQL datasource to an XA MySQL datasource. The configuration is listed below:

                   

                  Well, my point was that you don't have to do any changes to the DefaultDS configurations, since it doesn't come into picture (unless your application is using DefaultDS).

                   

                  My application is using the DefaultDS via JPA. As I eventually want to push the application in production, I should be able to use a persistent database like MySQL.

                   

                  jaikiran pai wrote:

                   

                  Frank Cornelis wrote:

                   

                  But despite this, and the fact that HornetQ uses XA per default AFAIK, the messages are not delivered to the MDB.

                   

                  From the jmx-console (there's MBean for your queue), do you see whether the message are present in the queue to which you are sending the messages?

                   

                  Well, I cheched out the org.hornetq:TrustServiceHarvester MBean and the MessageCount attribute is indeed increasing from 0 to 2. So it seems that the messages are never consumed by the MDB. What could cause this weird behavior? When using the default HSQLDB datasource the MDB works as expected, switching to the XA MySQL DefaultDS datasource breaks the MDB.

                  • 6. Re: JMS in JBoss AS 6.0.0.M3
                    Frank Cornelis Newbie

                    This is getting more weird by the hour. When I copy my EAR into server/all/deploy before I start JBoss, I get the following MDB activation exception by HornetQ when booting JBoss AS:

                     

                    15:13:29,072 ERROR [HornetQActivation] Unable to start activation : HornetQException[errorCode=105 message=Unable to validate user: null for check type CONSUME for address jms.queue.TrustServiceHarvester]
                        at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:287) [:6.0.0.20100429-M3]
                        at org.hornetq.core.client.impl.ClientSessionImpl.internalCreateConsumer(ClientSessionImpl.java:1556) [:6.0.0.20100429-M3]
                        at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:447) [:6.0.0.20100429-M3]
                        at org.hornetq.core.client.impl.ClientSessionImpl.createConsumer(ClientSessionImpl.java:392) [:6.0.0.20100429-M3]
                        at org.hornetq.core.client.impl.DelegatingSession.createConsumer(DelegatingSession.java:201) [:6.0.0.20100429-M3]
                        at org.hornetq.ra.inflow.HornetQMessageHandler.setup(HornetQMessageHandler.java:168) [:6.0.0.20100429-M3]
                        at org.hornetq.ra.inflow.HornetQActivation.setup(HornetQActivation.java:287) [:6.0.0.20100429-M3]
                        at org.hornetq.ra.inflow.HornetQActivation$SetupActivation.run(HornetQActivation.java:502) [:6.0.0.20100429-M3]
                        at org.jboss.resource.work.WorkWrapper.run(WorkWrapper.java:172) [:6.0.0.20100429-M3]
                        at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33) [:6.0.0.20100429-M3]
                        at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:780) [:6.0.0.20100429-M3]
                        at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45) [:6.0.0.20100429-M3]
                        at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:800) [:6.0.0.20100429-M3]
                        at java.lang.Thread.run(Thread.java:619) [:1.6.0_20]
                        at org.jboss.threads.JBossThread.run(JBossThread.java:122) [:6.0.0.20100429-M3]

                     

                    This is definitely the reason why the message delivery doesn't work. Now the funny thing is that if I first start JBoss without my EAR under server/all/deploy and then I copy (or using jmx-console to deploy) the EAR to server/all/deploy, I no longer receive the exception and the JMS message delivery works as expected.

                    • 7. Re: JMS in JBoss AS 6.0.0.M3
                      jaikiran pai Master

                      Looks like a dependency issue to me. Your MDB seems to be starting before the queue is deployed.

                       

                      Queues/Topics deployed through the earlier JBoss Messaging would create a corresponding MBean on which you could add a dependency. From what I know, HornetQ doesn't create MBeans for destinations. Let me see how a dependency can be added for HornetQ destination. I remember seeing a discussion about this, here in the forums.

                      • 8. Re: JMS in JBoss AS 6.0.0.M3
                        jaikiran pai Master

                        jaikiran pai wrote:

                         

                        Queues/Topics deployed through the earlier JBoss Messaging would create a corresponding MBean on which you could add a dependency. From what I know, HornetQ doesn't create MBeans for destinations.

                        Turns out, HornetQ does create MBeans for the destinations (you can find them under org.hornetq domain name in jmx-console).

                         

                        Add this to your MDB code and see if that prevents the exception:

                         

                        @org.jboss.ejb3.annotation.Depends("org.hornetq:module=JMS,name=\"TrustServiceHarvester\",type=Queue")
                        • 9. Re: JMS in JBoss AS 6.0.0.M3
                          jaikiran pai Master

                          If that @Depends doesn't work out, then do let us know the details about your application. Are you packaging any jboss.xml (with a security-domain element maybe)?

                           

                          I just re-read the stacktrace you posted and am not quite sure why its complaining about authentication problems:

                           

                          15:13:29,072 ERROR [HornetQActivation] Unable to start activation : HornetQException[errorCode=105 message=Unable to validate user: null for check type CONSUME for address jms.queue.TrustServiceHarvester]

                          From what I see in the hornetq-configuration, all addresses by default are configured to allow unauthenticated users (== with guest role) to consume messages. So I wouldn't expect this message in the stacktrace.

                          • 10. Re: JMS in JBoss AS 6.0.0.M3
                            Frank Cornelis Newbie

                            jaikiran pai wrote:

                             

                            jaikiran pai wrote:

                             

                            Queues/Topics deployed through the earlier JBoss Messaging would create a corresponding MBean on which you could add a dependency. From what I know, HornetQ doesn't create MBeans for destinations.

                            Turns out, HornetQ does create MBeans for the destinations (you can find them under org.hornetq domain name in jmx-console).

                             

                            Add this to your MDB code and see if that prevents the exception:

                             

                            @org.jboss.ejb3.annotation.Depends("org.hornetq:module=JMS,name=\"TrustServiceHarvester\",type=Queue")
                            

                            I've added the @Depends annotation to the MDB. Unfortunately this did not prevent the exception from occurring.

                            • 11. Re: JMS in JBoss AS 6.0.0.M3
                              jaikiran pai Master
                              I've added the @Depends annotation to the MDB. Unfortunately this did not prevent the exception from occurring.

                              Yeah, I kind of expected that after looking at the exception stacktrace in more detail. Hence, I had replied:

                               

                              jaikiran pai wrote:

                               

                              If that @Depends doesn't work out, then do let us know the details about your application. Are you packaging any jboss.xml (with a security-domain element maybe)?

                               

                              I just re-read the stacktrace you posted and am not quite sure why its complaining about authentication problems:

                               

                              15:13:29,072 ERROR [HornetQActivation] Unable to start activation : HornetQException[errorCode=105 message=Unable to validate user: null for check type CONSUME for address jms.queue.TrustServiceHarvester]

                              From what I see in the hornetq-configuration, all addresses by default are configured to allow unauthenticated users (== with guest role) to consume messages. So I wouldn't expect this message in the stacktrace.

                              • 12. Re: JMS in JBoss AS 6.0.0.M3
                                Frank Cornelis Newbie

                                jaikiran pai wrote:

                                 

                                I've added the @Depends annotation to the MDB. Unfortunately this did not prevent the exception from occurring.

                                Yeah, I kind of expected that after looking at the exception stacktrace in more detail. Hence, I had replied:

                                 

                                jaikiran pai wrote:

                                 

                                If that @Depends doesn't work out, then do let us know the details about your application. Are you packaging any jboss.xml (with a security-domain element maybe)?

                                My application EAR comes with a SAR that installs (via META-INF/jboss-service.xml) a DynamicLoginConfig MBean with its own JAAS login module. Some EJB3 beans live within the security domain via @SecurityDomain(TrustServiceConstants.ADMIN_SECURITY_DOMAIN) and thus use the @RolesAllowed annotation for RBAC. JAAS login happens via a servlet filter. The MDB and all the @EJB dependencies do not use the security domain at all. Of course some of the @EJB dependencies use an @PersistenceContext EntityManager.

                                It indeed seems that the HornetQ activation doesn't work because of some security constraint kicking in.

                                • 13. Re: JMS in JBoss AS 6.0.0.M3
                                  jaikiran pai Master

                                  Frank Cornelis wrote:

                                   

                                  My application EAR comes with a SAR that installs (via META-INF/jboss-service.xml) a DynamicLoginConfig MBean with its own JAAS login module. Some EJB3 beans live within the security domain via @SecurityDomain(TrustServiceConstants.ADMIN_SECURITY_DOMAIN) and thus use the @RolesAllowed annotation for RBAC. JAAS login happens via a servlet filter. The MDB and all the @EJB dependencies do not use the security domain at all. Of course some of the @EJB dependencies use an @PersistenceContext EntityManager.

                                  It indeed seems that the HornetQ activation doesn't work because of some security constraint kicking in.

                                  Could you enable the TRACE level logging of JBoss security package (as explained in Q4 here http://community.jboss.org/wiki/SecurityFAQ) and get the logs? Also could you post the login module configuration file(s) in your application?

                                  • 14. Re: JMS in JBoss AS 6.0.0.M3
                                    Frank Cornelis Newbie

                                    jaikiran pai wrote:

                                     

                                    Frank Cornelis wrote:

                                     

                                    My application EAR comes with a SAR that installs (via META-INF/jboss-service.xml) a DynamicLoginConfig MBean with its own JAAS login module. Some EJB3 beans live within the security domain via @SecurityDomain(TrustServiceConstants.ADMIN_SECURITY_DOMAIN) and thus use the @RolesAllowed annotation for RBAC. JAAS login happens via a servlet filter. The MDB and all the @EJB dependencies do not use the security domain at all. Of course some of the @EJB dependencies use an @PersistenceContext EntityManager.

                                    It indeed seems that the HornetQ activation doesn't work because of some security constraint kicking in.

                                    Could you enable the TRACE level logging of JBoss security package (as explained in Q4 here http://community.jboss.org/wiki/SecurityFAQ) and get the logs? Also could you post the login module configuration file(s) in your application?

                                     

                                    Actually I had to change the boot logging of JBoss (as explained in http://community.jboss.org/wiki/JBossBootLogging). Unfortunately the resulting logs don't reveal much. The entire application distribution (including the login module configuration) is available at http://eid-trust-service.googlecode.com/files/eid-trust-service-mysql-distribution-1.0.0-SNAPSHOT.zip

                                    1 2 Previous Next