Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0B21E7891 for ; Fri, 9 Dec 2011 14:39:02 +0000 (UTC) Received: (qmail 17919 invoked by uid 500); 9 Dec 2011 14:39:02 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 17893 invoked by uid 500); 9 Dec 2011 14:39:02 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 17886 invoked by uid 99); 9 Dec 2011 14:39:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Dec 2011 14:39:01 +0000 X-ASF-Spam-Status: No, hits=-2001.2 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Dec 2011 14:39:00 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 2A8FE109406 for ; Fri, 9 Dec 2011 14:38:40 +0000 (UTC) Date: Fri, 9 Dec 2011 14:38:40 +0000 (UTC) From: "Sergey Zhemzhitsky (Commented) (JIRA)" To: issues@camel.apache.org Message-ID: <289764442.58463.1323441520175.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1608460758.58106.1323435519979.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (CAMEL-4760) Unable to set logName on DefaultErrorHandler as well as executorService on LoggingErrorHandler MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-4760?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13166209#comment-13166209 ] Sergey Zhemzhitsky commented on CAMEL-4760: ------------------------------------------- Here is the unit test that proves asyncDelayedRedelivery can be used with logging error handler. {code:title=AsyncDelayedRedeliveryLogErrorHandlerTest.java} package org.foo.bar; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.processor.RedeliveryPolicy; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; import javax.naming.Context; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class AsyncDelayedRedeliveryLogErrorHandlerTest extends CamelTestSupport { @Test public void asyncRedeliveryTimer() throws Exception { context().addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .to("seda:next?waitForTaskToComplete=Never&size=10"); from("seda:next") .errorHandler(loggingErrorHandler()) .onException(Exception.class) .redeliveryPolicyRef("redeliveryPolicy") .handled(true) .to("mock:exception") .end() .process(new Processor() { private AtomicInteger counter = new AtomicInteger(); @Override public void process(Exchange exchange) throws Exception { if (counter.compareAndSet(1, 2)) { exchange.setProperty("ThrowException", Boolean.TRUE); exchange.getIn().setBody(counter.get() - 1); } else { exchange.getIn().setBody(counter.getAndIncrement()); } } }) .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { if (Boolean.TRUE.equals(exchange.getProperty("ThrowException", Boolean.class))) { exchange.removeProperty("ThrowException"); throw new RuntimeException("Test Exception!"); } } }) .to("mock:result"); } }); MockEndpoint result = getMockEndpoint("mock:result"); result.expectedMessageCount(5); result.allMessages().property("ThrowException").isNull(); // the 2nd sent message must be delivered 5th result.message(4).body().isEqualTo(1); // ensure there is no delay between the 1st and the 3rd sent messages result.message(1).arrives().noLaterThan(100).millis().afterPrevious(); startCamelContext(); for(int i = 0; i < 5; i++) { sendBody("direct:start", i); } assertMockEndpointsSatisfied(10, TimeUnit.SECONDS); } @Override protected Context createJndiContext() throws Exception { Context jndiContext = super.createJndiContext(); RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy(); redeliveryPolicy.setAsyncDelayedRedelivery(true); redeliveryPolicy.setMaximumRedeliveries(1); redeliveryPolicy.setRedeliveryDelay(5000); jndiContext.bind("redeliveryPolicy", redeliveryPolicy); return jndiContext; } @Override public boolean isUseRouteBuilder() { return false; } } {code} Please take a loot at assertions: {code} // the 2nd sent message must be delivered 5th result.message(4).body().isEqualTo(1); // ensure there is no delay between the 1st and the 3rd sent messages result.message(1).arrives().noLaterThan(100).millis().afterPrevious(); {code} The 2nd sent message is delivered 5th because of redelivery and the 2nd delivered message which is equal to 3rd sent message arrives no later than 100 millis after the first delivered message although _redeliveryDelay_ is equal to 5 seconds. That means I can configure async. redelivery with logging error handler, so I have two questions: # If I can configure async. redelivery with logging error handler why I cannot specify custom executor service, although logging error handler extends default error handler? # Is it possible to specify logName for default error handler, because it seems that spring dsl does not allow to specify logName for loggers although java dsl does? > Unable to set logName on DefaultErrorHandler as well as executorService on LoggingErrorHandler > ---------------------------------------------------------------------------------------------- > > Key: CAMEL-4760 > URL: https://issues.apache.org/jira/browse/CAMEL-4760 > Project: Camel > Issue Type: Improvement > Components: camel-spring > Affects Versions: 2.8.3 > Reporter: Sergey Zhemzhitsky > Assignee: Claus Ibsen > Priority: Minor > Fix For: 2.8.4, 2.9.0 > > > The following snippets do not work, although each of the specified error handlers supports _logName_ and _executorServiceRef_. The issue is actual for the _DeadLetterChannel_ error handler too. > {code:title=LoggingErrorHandler} > > {code} > {code:title=DefaultErrorHandler} > > {code} > {code:title=StackTrace} > Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/spring/camel-context.xml]; nested exception is java.lang.IllegalArgumentException: Attribute executorServiceRef is not supported by error handler type: LoggingErrorHandler, in error handler with id: errorHandler > at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412) > at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) > at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) > at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) > at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) > at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:186) > ... 42 more > Caused by: java.lang.IllegalArgumentException: Attribute executorServiceRef is not supported by error handler type: LoggingErrorHandler, in error handler with id: errorHandler > {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira