Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-4269

redelivery ResourceAdapter Config is not respected when defined in more than one config.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • 9.0.0.Alpha1
    • EJB
    • None
    • Hide
      • Start ActiveMQ 5.9.0 broker.
      • Get the ActiveMQ resource adapter 5.9.0 (behaviour is same in 5.8 rar as well)
      • Edit the WildFly "resource-adapter" subsystem configuration as following:
              <subsystem xmlns="urn:jboss:domain:resource-adapters:3.0">
                  <resource-adapters>
                      <resource-adapter id="activemq-rar-5.9.0.redhat-610379.rar">
                          <archive>
                              activemq-rar-5.9.0.redhat-610379.rar
                          </archive>
                          <transaction-support>XATransaction</transaction-support>
                          <config-property name="RedeliveryUseExponentialBackOff">
                              true
                          </config-property>
                          <config-property name="InitialRedeliveryDelay">
                              2000
                          </config-property>
                          <config-property name="MaximumRedeliveries">
                              3
                          </config-property>
                          <config-property name="RedeliveryBackOffMultiplier">
                              2
                          </config-property>
                          <config-property name="Password">
                              admin
                          </config-property>
                          <config-property name="UserName">
                              admin
                          </config-property>
                          <config-property name="ServerUrl">
                              tcp://localhost:61616
                          </config-property>
                          <connection-definitions>
                              <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:jboss/exported/activemq/ActiveMQQueueConnectionFactory" enabled="true" use-java-context="false" pool-name="java:/jms/ActiveMQPool" use-ccm="false">
                                  <xa-pool>
                                      <min-pool-size>10</min-pool-size>
                                      <max-pool-size>20</max-pool-size>
                                  </xa-pool>
                                  <recovery>
                                      <recover-credential>
                                          <user-name>admin</user-name>
                                          <password>admin</password>
                                      </recover-credential>
                                  </recovery>
                              </connection-definition>
                          </connection-definitions>
                          <admin-objects>
                              <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:jboss/exported/TestQ" use-java-context="false" pool-name="TestQ"/>
                          </admin-objects>
                      </resource-adapter>
                  </resource-adapters>
              </subsystem>
      
      • Configure the EJB3 subsystem to use the above resource adapter as following:
                  <mdb>
                      <resource-adapter-ref resource-adapter-name="activemq-rar-5.9.0.redhat-610379.rar"/>
                  </mdb>
      
      • Use the following MDB to notice the timestamps of message delivery and the to rollBack the messsages:
        package ejb30;
        import javax.ejb.MessageDriven;
        import javax.jms.JMSException;
        import javax.jms.Message;
        import javax.jms.MessageListener;
        import javax.jms.TextMessage;
        import javax.ejb.ActivationConfigProperty;
        import javax.naming.*;
        import javax.annotation.*;
        import javax.ejb.MessageDrivenContext;
        import javax.annotation.Resource;
        import org.jboss.ejb3.annotation.ResourceAdapter;
        
        @MessageDriven(activationConfig =
                {
                   @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
                   @ActivationConfigProperty(propertyName="destination", propertyValue="TestQ"),
                   @ActivationConfigProperty(propertyName = "maximumRedeliveries", propertyValue = "4"),
                   @ActivationConfigProperty(propertyName = "initialRedeliveryDelay", propertyValue = "7000"),
                })
        @ResourceAdapter("activemq-rar-5.9.0.redhat-610379.rar")
        
        public class TestMDB implements MessageListener{
        
            @Resource
            private MessageDrivenContext mdc;
        
            public void onMessage(Message message) {
                TextMessage textMessage = (TextMessage) message;
                try {
                      System.out.println("\n=> "+new java.util.Date()+"\tTestMDB Received Message >  "+textMessage.getText());
                      System.out.println("\tbefore mdc.setRollbackOnly()");
                      mdc.setRollbackOnly();
                      System.out.println("\tafter mdc.setRollbackOnly()");
                      
                } catch (JMSException e) {
                    e.printStackTrace();
                }
            }
        }
        

      NOTICE: MDB is also defining the "initialRedeliveryDelay" to 7 seconds.

      • Send some messages to the Activemq 5.9 broker and notice the WildFLy logs. Output as following:
      12:34:06,790 INFO  [stdout] (default-threads - 3) => Tue Jan 20 12:34:06 IST 2015	TestMDB Received Message >  Message - Hello One !!!Tue Jan 20 12:34:06 IST 2015
      12:34:06,790 INFO  [stdout] (default-threads - 3) 	before mdc.setRollbackOnly()
      12:34:06,790 INFO  [stdout] (default-threads - 3) 	after mdc.setRollbackOnly()
      12:34:07,797 INFO  [stdout] (default-threads - 4) 
      12:34:07,798 INFO  [stdout] (default-threads - 4) => Tue Jan 20 12:34:07 IST 2015	TestMDB Received Message >  Message - Hello One !!!Tue Jan 20 12:34:06 IST 2015
      12:34:07,798 INFO  [stdout] (default-threads - 4) 	before mdc.setRollbackOnly()
      12:34:07,798 INFO  [stdout] (default-threads - 4) 	after mdc.setRollbackOnly()
      12:34:08,801 INFO  [stdout] (default-threads - 5) 
      12:34:08,801 INFO  [stdout] (default-threads - 5) => Tue Jan 20 12:34:08 IST 2015	TestMDB Received Message >  Message - Hello One !!!Tue Jan 20 12:34:06 IST 2015
      12:34:08,801 INFO  [stdout] (default-threads - 5) 	before mdc.setRollbackOnly()
      12:34:08,802 INFO  [stdout] (default-threads - 5) 	after mdc.setRollbackOnly()
      12:34:09,805 INFO  [stdout] (default-threads - 6) 
      12:34:09,805 INFO  [stdout] (default-threads - 6) => Tue Jan 20 12:34:09 IST 2015	TestMDB Received Message >  Message - Hello One !!!Tue Jan 20 12:34:06 IST 2015
      12:34:09,806 INFO  [stdout] (default-threads - 6) 	before mdc.setRollbackOnly()
      12:34:09,806 INFO  [stdout] (default-threads - 6) 	after mdc.setRollbackOnly()
      12:34:10,809 INFO  [stdout] (default-threads - 7) 
      12:34:10,810 INFO  [stdout] (default-threads - 7) => Tue Jan 20 12:34:10 IST 2015	TestMDB Received Message >  Message - Hello One !!!Tue Jan 20 12:34:06 IST 2015
      12:34:10,810 INFO  [stdout] (default-threads - 7) 	before mdc.setRollbackOnly()
      12:34:10,810 INFO  [stdout] (default-threads - 7) 	after mdc.setRollbackOnly()
      
      Show
      Start ActiveMQ 5.9.0 broker. Get the ActiveMQ resource adapter 5.9.0 (behaviour is same in 5.8 rar as well) Edit the WildFly "resource-adapter" subsystem configuration as following: <subsystem xmlns= "urn:jboss:domain:resource-adapters:3.0" > <resource-adapters> <resource-adapter id= "activemq-rar-5.9.0.redhat-610379.rar" > <archive> activemq-rar-5.9.0.redhat-610379.rar </archive> <transaction-support>XATransaction</transaction-support> <config-property name= "RedeliveryUseExponentialBackOff" > true </config-property> <config-property name= "InitialRedeliveryDelay" > 2000 </config-property> <config-property name= "MaximumRedeliveries" > 3 </config-property> <config-property name= "RedeliveryBackOffMultiplier" > 2 </config-property> <config-property name= "Password" > admin </config-property> <config-property name= "UserName" > admin </config-property> <config-property name= "ServerUrl" > tcp: //localhost:61616 </config-property> <connection-definitions> <connection-definition class- name= "org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name= "java:jboss/exported/activemq/ActiveMQQueueConnectionFactory" enabled= " true " use-java-context= " false " pool-name= "java:/jms/ActiveMQPool" use-ccm= " false " > <xa-pool> <min-pool-size>10</min-pool-size> <max-pool-size>20</max-pool-size> </xa-pool> <recovery> <recover-credential> <user-name>admin</user-name> <password>admin</password> </recover-credential> </recovery> </connection-definition> </connection-definitions> <admin-objects> <admin-object class- name= "org.apache.activemq.command.ActiveMQQueue" jndi-name= "java:jboss/exported/TestQ" use-java-context= " false " pool-name= "TestQ" /> </admin-objects> </resource-adapter> </resource-adapters> </subsystem> Configure the EJB3 subsystem to use the above resource adapter as following: <mdb> <resource-adapter-ref resource-adapter-name= "activemq-rar-5.9.0.redhat-610379.rar" /> </mdb> Use the following MDB to notice the timestamps of message delivery and the to rollBack the messsages: package ejb30; import javax.ejb.MessageDriven; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.TextMessage; import javax.ejb.ActivationConfigProperty; import javax.naming.*; import javax.annotation.*; import javax.ejb.MessageDrivenContext; import javax.annotation.Resource; import org.jboss.ejb3.annotation.ResourceAdapter; @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName= "destinationType" , propertyValue= "javax.jms.Queue" ), @ActivationConfigProperty(propertyName= "destination" , propertyValue= "TestQ" ), @ActivationConfigProperty(propertyName = "maximumRedeliveries" , propertyValue = "4" ), @ActivationConfigProperty(propertyName = "initialRedeliveryDelay" , propertyValue = "7000" ), }) @ResourceAdapter( "activemq-rar-5.9.0.redhat-610379.rar" ) public class TestMDB implements MessageListener{ @Resource private MessageDrivenContext mdc; public void onMessage(Message message) { TextMessage textMessage = (TextMessage) message; try { System .out.println( "\n=> " + new java.util.Date()+ "\tTestMDB Received Message > " +textMessage.getText()); System .out.println( "\tbefore mdc.setRollbackOnly()" ); mdc.setRollbackOnly(); System .out.println( "\tafter mdc.setRollbackOnly()" ); } catch (JMSException e) { e.printStackTrace(); } } } NOTICE: MDB is also defining the "initialRedeliveryDelay" to 7 seconds. Send some messages to the Activemq 5.9 broker and notice the WildFLy logs. Output as following: 12:34:06,790 INFO [stdout] ( default -threads - 3) => Tue Jan 20 12:34:06 IST 2015 TestMDB Received Message > Message - Hello One !!!Tue Jan 20 12:34:06 IST 2015 12:34:06,790 INFO [stdout] ( default -threads - 3) before mdc.setRollbackOnly() 12:34:06,790 INFO [stdout] ( default -threads - 3) after mdc.setRollbackOnly() 12:34:07,797 INFO [stdout] ( default -threads - 4) 12:34:07,798 INFO [stdout] ( default -threads - 4) => Tue Jan 20 12:34:07 IST 2015 TestMDB Received Message > Message - Hello One !!!Tue Jan 20 12:34:06 IST 2015 12:34:07,798 INFO [stdout] ( default -threads - 4) before mdc.setRollbackOnly() 12:34:07,798 INFO [stdout] ( default -threads - 4) after mdc.setRollbackOnly() 12:34:08,801 INFO [stdout] ( default -threads - 5) 12:34:08,801 INFO [stdout] ( default -threads - 5) => Tue Jan 20 12:34:08 IST 2015 TestMDB Received Message > Message - Hello One !!!Tue Jan 20 12:34:06 IST 2015 12:34:08,801 INFO [stdout] ( default -threads - 5) before mdc.setRollbackOnly() 12:34:08,802 INFO [stdout] ( default -threads - 5) after mdc.setRollbackOnly() 12:34:09,805 INFO [stdout] ( default -threads - 6) 12:34:09,805 INFO [stdout] ( default -threads - 6) => Tue Jan 20 12:34:09 IST 2015 TestMDB Received Message > Message - Hello One !!!Tue Jan 20 12:34:06 IST 2015 12:34:09,806 INFO [stdout] ( default -threads - 6) before mdc.setRollbackOnly() 12:34:09,806 INFO [stdout] ( default -threads - 6) after mdc.setRollbackOnly() 12:34:10,809 INFO [stdout] ( default -threads - 7) 12:34:10,810 INFO [stdout] ( default -threads - 7) => Tue Jan 20 12:34:10 IST 2015 TestMDB Received Message > Message - Hello One !!!Tue Jan 20 12:34:06 IST 2015 12:34:10,810 INFO [stdout] ( default -threads - 7) before mdc.setRollbackOnly() 12:34:10,810 INFO [stdout] ( default -threads - 7) after mdc.setRollbackOnly()
    • Workaround Exists
    • Hide

      Define all the resource adapter config properties via <config-property> tag in resource -adapter section of the profile.

      Show
      Define all the resource adapter config properties via <config-property> tag in resource -adapter section of the profile.

    Description

      • If the MDB defines the "initialRedeliveryDelay" and "maximumRedeliveries" ActivationConfigProperty via annotation OR using "ejb-jar.xml" file, As well as if the "initialRedeliveryDelay" "config-property" is defined inside the <resource-adapter> section of standalone.xml then both are ignored, and it starts taking the default value of initialRedeliveryDelay for Activemq resource adapter as 1 Second see [1]

      [1] http://activemq.apache.org/redelivery-policy.html

      Attachments

        Activity

          People

            Unassigned Unassigned
            jaysensharma Jay SenSharma (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: