activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r386654 - in /incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra: ActiveMQActivationSpec.java ActiveMQResourceAdapter.java
Date Fri, 17 Mar 2006 15:19:57 GMT
Author: jstrachan
Date: Fri Mar 17 07:19:56 2006
New Revision: 386654

URL: http://svn.apache.org/viewcvs?rev=386654&view=rev
Log:
added the ability to configure the redelivery policy on the activation spec

Modified:
    incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQActivationSpec.java
    incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java

Modified: incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQActivationSpec.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQActivationSpec.java?rev=386654&r1=386653&r2=386654&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQActivationSpec.java
(original)
+++ incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQActivationSpec.java
Fri Mar 17 07:19:56 2006
@@ -31,6 +31,7 @@
 import javax.resource.spi.InvalidPropertyException;
 import javax.resource.spi.ResourceAdapter;
 
+import org.apache.activemq.RedeliveryPolicy;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTopic;
@@ -74,6 +75,7 @@
     private String maxMessagesPerSessions="10";
     private String enableBatch = "false";
     private String maxMessagesPerBatch = "10";
+    private RedeliveryPolicy redeliveryPolicy;
 
     
     /**
@@ -536,4 +538,60 @@
         }
     }
 
+    public short getBackOffMultiplier() {
+        if (redeliveryPolicy == null) {
+            return 0;
+        }
+        return redeliveryPolicy.getBackOffMultiplier();
+    }
+
+    public long getInitialRedeliveryDelay() {
+        if (redeliveryPolicy == null) {
+            return 0;
+        }
+        return redeliveryPolicy.getInitialRedeliveryDelay();
+    }
+
+    public int getMaximumRedeliveries() {
+        if (redeliveryPolicy == null) {
+            return 0;
+        }
+        return redeliveryPolicy.getMaximumRedeliveries();
+    }
+
+    public boolean isUseExponentialBackOff() {
+        if (redeliveryPolicy == null) {
+            return false;
+        }
+        return redeliveryPolicy.isUseExponentialBackOff();
+    }
+
+    public void setBackOffMultiplier(short backOffMultiplier) {
+        lazyCreateRedeliveryPolicy().setBackOffMultiplier(backOffMultiplier);
+    }
+
+    public void setInitialRedeliveryDelay(long initialRedeliveryDelay) {
+        lazyCreateRedeliveryPolicy().setInitialRedeliveryDelay(initialRedeliveryDelay);
+    }
+
+    public void setMaximumRedeliveries(int maximumRedeliveries) {
+        lazyCreateRedeliveryPolicy().setMaximumRedeliveries(maximumRedeliveries);
+    }
+
+    public void setUseExponentialBackOff(boolean useExponentialBackOff) {
+        lazyCreateRedeliveryPolicy().setUseExponentialBackOff(useExponentialBackOff);
+    }
+
+    // don't use getter to avoid causing introspection errors in containers
+    public RedeliveryPolicy redeliveryPolicy() {
+        return redeliveryPolicy;
+    }
+    
+    protected RedeliveryPolicy lazyCreateRedeliveryPolicy() {
+        if (redeliveryPolicy == null) {
+            redeliveryPolicy = new RedeliveryPolicy();
+        }
+        return redeliveryPolicy;
+    }
 }
+

Modified: incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java?rev=386654&r1=386653&r2=386654&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java
(original)
+++ incubator/activemq/trunk/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQResourceAdapter.java
Fri Mar 17 07:19:56 2006
@@ -18,6 +18,7 @@
 
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.RedeliveryPolicy;
 import org.apache.activemq.broker.BrokerFactory;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.util.ServiceSupport;
@@ -129,6 +130,12 @@
             }
         }
         ActiveMQConnection physicalConnection = (ActiveMQConnection) connectionFactory.createConnection(userName,
password);
+
+        // have we configured a redelivery policy
+        RedeliveryPolicy redeliveryPolicy = activationSpec.redeliveryPolicy();
+        if (redeliveryPolicy != null) {
+            physicalConnection.setRedeliveryPolicy(redeliveryPolicy);
+        }
         return physicalConnection;
     }
 



Mime
View raw message