[jboss-svn-commits] JBL Code SVN: r24373 - labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Dec 14 12:48:13 EST 2008


Author: mark.little at jboss.com
Date: 2008-12-14 12:48:11 -0500 (Sun, 14 Dec 2008)
New Revision: 24373

Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
Log:
https://jira.jboss.org/jira/browse/JBESB-2003

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java	2008-12-14 17:41:37 UTC (rev 24372)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/client/ServiceInvoker.java	2008-12-14 17:48:11 UTC (rev 24373)
@@ -192,6 +192,10 @@
      * Synchronously deliver the supplied message to the target service associated with this invoker instance.
      * If the To field of the Message is set, then it will be ignored in favour of the equivalent information
      * obtained through the parameters provided during instance construction.
+     * 
+     * Redelivery on failure can be defined by setting the global org.jboss.soa.esb.dls.redeliver property in
+     * the configuration file or by setting it on a per message basis as a message property. The message property
+     * will be used in preference to the global value.
      *
      * @param message       The message to be delivered.
      * @param timeoutMillis Number of milliseconds before synchronous reply pickup should timeout.
@@ -205,8 +209,7 @@
         try {
             message = post(message, new EPRInvoker(timeoutMillis));
         } catch (MessageDeliverException mde) {
-            if ("true".equalsIgnoreCase(Configuration.getRedeliveryDlsOn())
-                    && !service.equals(dlqService)) {
+            if (asyncRedelivery(message) && !service.equals(dlqService)) {
                 //Send a copy to the DLQ, no retries for syncDeliveries
                 message.getProperties().setProperty(DELIVER_TO, service);
 
@@ -223,6 +226,10 @@
      * Asynchronously deliver the supplied message to the target service associated with this invoker instance.
      * If the To field of the Message is set, then it will be ignored in favour of the equivalent information
      * obtained through the parameters provided during instance construction.
+     * 
+     * Redelivery on failure can be defined by setting the global org.jboss.soa.esb.dls.redeliver property in
+     * the configuration file or by setting it on a per message basis as a message property. The message property
+     * will be used in preference to the global value.
      *
      * @param message The message to be delivered.
      * @throws MessageDeliverException Failed to deliver message, after trying all available EPRs.
@@ -235,7 +242,7 @@
             post(message, new EPRInvoker());
         } catch (MessageDeliverException mde) {
             if (message.getProperties().getProperty(RedeliverStore.IS_REDELIVERY)==null
-                    && "true".equalsIgnoreCase(Configuration.getRedeliveryDlsOn())
+                    && asyncRedelivery(message)
                     && !service.equals(dlqService)) {
                 message.getProperties().setProperty(MessageStore.CLASSIFICATION, MessageStore.CLASSIFICATION_RDLVR);
                 message.getProperties().setProperty(DELIVER_TO, service);
@@ -476,7 +483,25 @@
         serviceClusterInfo = new ServiceClusterInfoImpl(service.getName(), serviceEprs);
         expirationDate = new Date(java.lang.System.currentTimeMillis() + registryCacheLife);
     }
-
+    
+    /*
+     * Is redelivery overridden on a per message basis? If not, use the global setting.
+     */
+    
+    private boolean asyncRedelivery (final Message message)
+    {
+        Object perMessage = message.getProperties().getProperty(Environment.REDELIVER_DLS_SERVICE_ON);
+        
+        if (perMessage == null) // user does not care so use the global property
+            return "true".equalsIgnoreCase(Configuration.getRedeliveryDlsOn());
+        else
+        {
+            // use whatever is set on the message in preference to global value
+            
+            return "true".equalsIgnoreCase((String) perMessage);
+        }
+    }
+    
     private class EPRInvoker {
 
         private boolean synchronous = false;




More information about the jboss-svn-commits mailing list