[mule-dev] Re: [mule-scm] [mule][24719] branches/mule-3.2.x: EE-2661 - improving until-successful to call exception strategy in case that the retries is exhausted and no DLQ mp defined , or DLQ mp execution fails

18 views
Skip to first unread message

Daniel Feist

unread,
Aug 8, 2012, 8:25:35 PM8/8/12
to d...@mule.codehaus.org, s...@mule.codehaus.org
Remember to use CE JIRA's for CE source code!


On Aug 8, 2012, at 7:21 PM, pablo....@codehaus.org wrote:

Revision
24719
Author
pablo.lagreca
Date
2012-08-08 17:21:54 -0500 (Wed, 08 Aug 2012)

Log Message

EE-2661 - improving until-successful to call exception strategy in case that the retries is exhausted and no DLQ mp defined, or DLQ mp execution fails

Modified Paths

Added Paths

Diff

Modified: branches/mule-3.2.x/core/src/main/java/org/mule/routing/UntilSuccessful.java (24718 => 24719)


--- branches/mule-3.2.x/core/src/main/java/org/mule/routing/UntilSuccessful.java	2012-08-08 17:26:45 UTC (rev 24718)
+++ branches/mule-3.2.x/core/src/main/java/org/mule/routing/UntilSuccessful.java	2012-08-08 22:21:54 UTC (rev 24719)
@@ -27,7 +27,9 @@
 import org.mule.api.retry.RetryPolicyTemplate;
 import org.mule.api.store.ListableObjectStore;
 import org.mule.api.store.ObjectStoreException;
+import org.mule.config.i18n.CoreMessages;
 import org.mule.config.i18n.MessageFactory;
+import org.mule.retry.RetryPolicyExhaustedException;
 import org.mule.retry.async.AsynchronousRetryTemplate;
 import org.mule.retry.policies.SimpleRetryPolicyTemplate;
 import org.mule.routing.filters.ExpressionFilter;
@@ -302,19 +304,25 @@
     {
         if (dlqMP == null)
         {
-            logger.info("Retry attempts exhausted and no DLQ defined, dropping message: " + event);
+            logger.info("Retry attempts exhausted and no DLQ defined");
+            RetryPolicyExhaustedException retryPolicyExhaustedException = new RetryPolicyExhaustedException(CoreMessages.createStaticMessage("until-successful retries exhausted"), this);
+            event.getFlowConstruct().getExceptionListener().handleException(new MessagingException(event,retryPolicyExhaustedException),event);
             return;
         }
 
+        logger.info("Retry attempts exhausted, routing message to DLQ: " + dlqMP);
         try
         {
-            logger.info("Retry attempts exhausted, routing message to DLQ: " + dlqMP);
             dlqMP.process(mutableEvent);
         }
-        catch (final MuleException me)
+        catch (MessagingException e)
         {
-            logger.error("Failed to route message to DLQ: " + dlqMP + ", dropping message: " + event, me);
+            event.getFlowConstruct().getExceptionListener().handleException(e,event);
         }
+        catch (Exception e)
+        {
+            event.getFlowConstruct().getExceptionListener().handleException(new MessagingException(event,e),event);
+        }
     }
 
     private void removeFromStore(final Serializable eventStoreKey)

Added: branches/mule-3.2.x/tests/integration/src/test/java/org/mule/test/integration/routing/outbound/UntilSuccessfulRetryExhaustedTestCase.java (0 => 24719)


--- branches/mule-3.2.x/tests/integration/src/test/java/org/mule/test/integration/routing/outbound/UntilSuccessfulRetryExhaustedTestCase.java	                        (rev 0)
+++ branches/mule-3.2.x/tests/integration/src/test/java/org/mule/test/integration/routing/outbound/UntilSuccessfulRetryExhaustedTestCase.java	2012-08-08 22:21:54 UTC (rev 24719)
@@ -0,0 +1,40 @@
+package org.mule.test.integration.routing.outbound;
+
+import org.junit.Test;
+import org.mule.api.context.notification.ExceptionNotificationListener;
+import org.mule.construct.Flow;
+import org.mule.context.notification.ExceptionNotification;
+import org.mule.tck.junit4.FunctionalTestCase;
+import org.mule.util.concurrent.Latch;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.fail;
+
+public class UntilSuccessfulRetryExhaustedTestCase extends FunctionalTestCase
+{
+    @Override
+    protected String getConfigResources()
+    {
+        return "org/mule/test/integration/routing/outbound/until-successful-retry-exhausted.xml";
+    }
+    
+    @Test
+    public void onRetryExhaustedCallExceptionStrategy() throws Exception
+    {
+        final Latch exceptionStrategyCalledLatch = new Latch();
+        muleContext.registerListener(new ExceptionNotificationListener<ExceptionNotification>() {
+            @Override
+            public void onNotification(ExceptionNotification notification)
+            {
+                exceptionStrategyCalledLatch.release();   
+            }
+        });
+        Flow flow = (Flow) getFlowConstruct("retryExhausted");
+        flow.process(getTestEvent("message"));
+        if (!exceptionStrategyCalledLatch.await(10000, TimeUnit.MILLISECONDS))
+        {
+            fail("exception strategy was not executed");
+        }
+    }
+}
Property changes on: branches/mule-3.2.x/tests/integration/src/test/java/org/mule/test/integration/routing/outbound/UntilSuccessfulRetryExhaustedTestCase.java
___________________________________________________________________

Added: svn:keywords

Added: svn:eol-style

Added: branches/mule-3.2.x/tests/integration/src/test/resources/org/mule/test/integration/routing/outbound/until-successful-retry-exhausted.xml (0 => 24719)


--- branches/mule-3.2.x/tests/integration/src/test/resources/org/mule/test/integration/routing/outbound/until-successful-retry-exhausted.xml	                        (rev 0)
+++ branches/mule-3.2.x/tests/integration/src/test/resources/org/mule/test/integration/routing/outbound/until-successful-retry-exhausted.xml	2012-08-08 22:21:54 UTC (rev 24719)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:spring="http://www.springframework.org/schema/beans"
+    xmlns:test="http://www.mulesoft.org/schema/mule/test"
+	xsi:schemaLocation="
+        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
+        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+        http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/3.2/mule-test.xsd">
+
+	<spring:bean id="objectStore"
+		class="org.mule.util.store.SimpleMemoryObjectStore" />
+
+	<flow name="retryExhausted">
+		<until-successful objectStore-ref="objectStore" maxRetries="1" secondsBetweenRetries="1">
+			<test:component throwException="true"/>
+		</until-successful>
+		<default-exception-strategy/>
+	</flow>
+</mule>
Property changes on: branches/mule-3.2.x/tests/integration/src/test/resources/org/mule/test/integration/routing/outbound/until-successful-retry-exhausted.xml
___________________________________________________________________

Added: svn:keywords

Added: svn:eol-style


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email


Pablo Kraan

unread,
Aug 9, 2012, 7:14:44 AM8/9/12
to d...@mule.codehaus.org, s...@mule.codehaus.org
Add missing headers to java class!
Reply all
Reply to author
Forward
0 new messages