- 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 failsModified 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: