Timer endpoint and errorHandler

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Timer endpoint and errorHandler

arhan
Hi,

See the code snipped below.
I'm using the timer endpoint to execute some route periodically, and it works until I add error handler. If errorHandler(..) is included, the process doesn't stay up and running but instead it does all the initialization and exits gracefully.


RouteBuilder routeBuilder = new RouteBuilder(){
   public void configure() throws Exception {

     onException(RuntimeCamelException.class).handled(true);
     errorHandler(loggingErrorHandler(getClass().getName()));  //Here's the problem

      String executionTriggerUri = "timer:executionTimer"
                                 + "?fixedRate=true"
                                 + "&daemon=true"
                                 + "&period=5000";

     from(executionTriggerUri).to("bean:someBean");
   }
}
Reply | Threaded
Open this post in threaded view
|

Re: Timer endpoint and errorHandler

Claus Ibsen-2
Hi

On Mon, May 4, 2009 at 3:07 PM, arhan <[hidden email]> wrote:
>
> Hi,
>
> See the code snipped below.
> I'm using the timer endpoint to execute some route periodically, and it
> works until I add error handler. If errorHandler(..) is included, the
> process doesn't stay up and running but instead it does all the
> initialization and exits gracefully.
I just added unit test in Camel 2.0 that looks like you route and it works:
http://svn.apache.org/viewvc?view=rev&revision=771312

What version of Camel are you using?

The reason could be the body message is null, as the timer does not
create any input message.
There was such a bug in Camel 1.3/1.4 when using the tracer.

You can try adding
.setBody(constant(""))

>
>
> RouteBuilder routeBuilder = new RouteBuilder(){
>   public void configure() throws Exception {
>
>     onException(RuntimeCamelException.class).handled(true);
>     errorHandler(loggingErrorHandler(getClass().getName()));  //Here's the
> problem
>
>      String executionTriggerUri = "timer:executionTimer"
>                                 + "?fixedRate=true"
>                                 + "&daemon=true"
>                                 + "&period=5000";
>
>     from(executionTriggerUri).to("bean:someBean");
>   }
> }
> --
> View this message in context: http://www.nabble.com/Timer-endpoint-and-errorHandler-tp23366970p23366970.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Reply | Threaded
Open this post in threaded view
|

Re: Timer endpoint and errorHandler

arhan
Hi!

I tried it with 2.0-M1

Claus Ibsen-2 wrote
I just added unit test in Camel 2.0 that looks like you route and it works:
http://svn.apache.org/viewvc?view=rev&revision=771312

What version of Camel are you using?

The reason could be the body message is null, as the timer does not
create any input message.
There was such a bug in Camel 1.3/1.4 when using the tracer.

You can try adding
.setBody(constant(""))
Reply | Threaded
Open this post in threaded view
|

Re: Timer endpoint and errorHandler

Claus Ibsen-2
On Mon, May 4, 2009 at 6:06 PM, arhan <[hidden email]> wrote:
>
> Hi!
>
> I tried it with 2.0-M1
Well I am surprised. The unit test I added is 2.0-SNAPSHOT.

How do you start/run Camel? Could be something there. And what is
logged in the output when you say it "hangs"?
And how have you defined your bean?

You can also try out the SNAPSHOT version. A m2 is scheduled to be
build and released soon. The person doing this is however a bit tight
work other work.
But there is a topic on the camel dev forum about that release being
in progress.

The snapshot can be downloaded and/or use maven. See this page:
http://camel.apache.org/download.html

>
>
> Claus Ibsen-2 wrote:
>>
>>
>> I just added unit test in Camel 2.0 that looks like you route and it
>> works:
>> http://svn.apache.org/viewvc?view=rev&revision=771312
>>
>> What version of Camel are you using?
>>
>> The reason could be the body message is null, as the timer does not
>> create any input message.
>> There was such a bug in Camel 1.3/1.4 when using the tracer.
>>
>> You can try adding
>> .setBody(constant(""))
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Timer-endpoint-and-errorHandler-tp23366970p23371453.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Reply | Threaded
Open this post in threaded view
|

Re: Timer endpoint and errorHandler

arhan
Seems that I found the difference, but have no solution yet.

Sorry, I wasn't specific enough at first.

Instead of starting the app using org.apache.camel.spring.Main class, I'm starting it just using the Spring context:

public class App {
  public static void main(String[] args) {
    new ClassPathXmlApplicationContext("config.xml").start();
  }
}

And the route class:

public class Route extends SpringRouteBuilder {
  public void configure() throws Exception {
    onException(RuntimeCamelException.class);
    errorHandler(loggingErrorHandler(getClass().getName()));
    from("timer:hello?daemon=true&period=2000").to("log:myLogger?level=INFO");
  }
}

The route triggers only once, producing the following output:
May 4, 2009 8:07:56 PM org.apache.camel.impl.DefaultCamelContext doStart
INFO: Apache Camel 2.0-M1 (CamelContext:camel) is starting
May 4, 2009 8:07:57 PM org.apache.camel.impl.DefaultCamelContext doStart
INFO: Apache Camel 2.0-M1 (CamelContext:camel) started
May 4, 2009 8:07:57 PM org.apache.camel.processor.Logger process
INFO: Exchange[BodyType:null, Body:null]


This is with 2.0-M1. Will try the SNAPSHOT version a bit later.


Claus Ibsen-2 wrote
On Mon, May 4, 2009 at 6:06 PM, arhan <ant.arhipov@gmail.com> wrote:
>
> Hi!
>
> I tried it with 2.0-M1
Well I am surprised. The unit test I added is 2.0-SNAPSHOT.

How do you start/run Camel? Could be something there. And what is
logged in the output when you say it "hangs"?
And how have you defined your bean?

You can also try out the SNAPSHOT version. A m2 is scheduled to be
build and released soon. The person doing this is however a bit tight
work other work.
But there is a topic on the camel dev forum about that release being
in progress.

The snapshot can be downloaded and/or use maven. See this page:
http://camel.apache.org/download.html

>
>
> Claus Ibsen-2 wrote:
>>
>>
>> I just added unit test in Camel 2.0 that looks like you route and it
>> works:
>> http://svn.apache.org/viewvc?view=rev&revision=771312
>>
>> What version of Camel are you using?
>>
>> The reason could be the body message is null, as the timer does not
>> create any input message.
>> There was such a bug in Camel 1.3/1.4 when using the tracer.
>>
>> You can try adding
>> .setBody(constant(""))
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Timer-endpoint-and-errorHandler-tp23366970p23371453.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Reply | Threaded
Open this post in threaded view
|

Re: Timer endpoint and errorHandler

Willem.Jiang
Administrator
Hi,

Can you also show us the "config.xml", it will help us to find the key
of this issue.

Willem

arhan wrote:

> Seems that I found the difference, but have no solution yet.
>
> Sorry, I wasn't specific enough at first.
>
> Instead of starting the app using org.apache.camel.spring.Main class, I'm
> starting it just using the Spring context:
>
> public class App {
>   public static void main(String[] args) {
>     new ClassPathXmlApplicationContext("config.xml").start();
>   }
> }
>
> And the route class:
>
> public class Route extends SpringRouteBuilder {
>   public void configure() throws Exception {
>     onException(RuntimeCamelException.class);
>     errorHandler(loggingErrorHandler(getClass().getName()));
>    
> from("timer:hello?daemon=true&period=2000").to("log:myLogger?level=INFO");
>   }
> }
>
> The route triggers only once, producing the following output:
> May 4, 2009 8:07:56 PM org.apache.camel.impl.DefaultCamelContext doStart
> INFO: Apache Camel 2.0-M1 (CamelContext:camel) is starting
> May 4, 2009 8:07:57 PM org.apache.camel.impl.DefaultCamelContext doStart
> INFO: Apache Camel 2.0-M1 (CamelContext:camel) started
> May 4, 2009 8:07:57 PM org.apache.camel.processor.Logger process
> INFO: Exchange[BodyType:null, Body:null]
>
>
> This is with 2.0-M1. Will try the SNAPSHOT version a bit later.
>
>
>
> Claus Ibsen-2 wrote:
>> On Mon, May 4, 2009 at 6:06 PM, arhan <[hidden email]> wrote:
>>> Hi!
>>>
>>> I tried it with 2.0-M1
>> Well I am surprised. The unit test I added is 2.0-SNAPSHOT.
>>
>> How do you start/run Camel? Could be something there. And what is
>> logged in the output when you say it "hangs"?
>> And how have you defined your bean?
>>
>> You can also try out the SNAPSHOT version. A m2 is scheduled to be
>> build and released soon. The person doing this is however a bit tight
>> work other work.
>> But there is a topic on the camel dev forum about that release being
>> in progress.
>>
>> The snapshot can be downloaded and/or use maven. See this page:
>> http://camel.apache.org/download.html
>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> I just added unit test in Camel 2.0 that looks like you route and it
>>>> works:
>>>> http://svn.apache.org/viewvc?view=rev&revision=771312
>>>>
>>>> What version of Camel are you using?
>>>>
>>>> The reason could be the body message is null, as the timer does not
>>>> create any input message.
>>>> There was such a bug in Camel 1.3/1.4 when using the tracer.
>>>>
>>>> You can try adding
>>>> .setBody(constant(""))
>>>>
>>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Timer-endpoint-and-errorHandler-tp23366970p23371453.html
>>> Sent from the Camel - Users (activemq) mailing list archive at
>>> Nabble.com.
>>>
>>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>> Apache Camel Reference Card:
>> http://refcardz.dzone.com/refcardz/enterprise-integration
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Timer endpoint and errorHandler

arhan
Willem, sure! Here it is:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <package>my.timer</package>
  </camelContext>

</beans>

The route builder actually resides in my.timer package.


willem.jiang wrote
Hi,

Can you also show us the "config.xml", it will help us to find the key
of this issue.

Willem

arhan wrote:
> Seems that I found the difference, but have no solution yet.
>
> Sorry, I wasn't specific enough at first.
>
> Instead of starting the app using org.apache.camel.spring.Main class, I'm
> starting it just using the Spring context:
>
> public class App {
>   public static void main(String[] args) {
>     new ClassPathXmlApplicationContext("config.xml").start();
>   }
> }
>
> And the route class:
>
> public class Route extends SpringRouteBuilder {
>   public void configure() throws Exception {
>     onException(RuntimeCamelException.class);
>     errorHandler(loggingErrorHandler(getClass().getName()));
>    
> from("timer:hello?daemon=true&period=2000").to("log:myLogger?level=INFO");
>   }
> }
>
> The route triggers only once, producing the following output:
> May 4, 2009 8:07:56 PM org.apache.camel.impl.DefaultCamelContext doStart
> INFO: Apache Camel 2.0-M1 (CamelContext:camel) is starting
> May 4, 2009 8:07:57 PM org.apache.camel.impl.DefaultCamelContext doStart
> INFO: Apache Camel 2.0-M1 (CamelContext:camel) started
> May 4, 2009 8:07:57 PM org.apache.camel.processor.Logger process
> INFO: Exchange[BodyType:null, Body:null]
>
>
> This is with 2.0-M1. Will try the SNAPSHOT version a bit later.
>
>
>
> Claus Ibsen-2 wrote:
>> On Mon, May 4, 2009 at 6:06 PM, arhan <ant.arhipov@gmail.com> wrote:
>>> Hi!
>>>
>>> I tried it with 2.0-M1
>> Well I am surprised. The unit test I added is 2.0-SNAPSHOT.
>>
>> How do you start/run Camel? Could be something there. And what is
>> logged in the output when you say it "hangs"?
>> And how have you defined your bean?
>>
>> You can also try out the SNAPSHOT version. A m2 is scheduled to be
>> build and released soon. The person doing this is however a bit tight
>> work other work.
>> But there is a topic on the camel dev forum about that release being
>> in progress.
>>
>> The snapshot can be downloaded and/or use maven. See this page:
>> http://camel.apache.org/download.html
>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> I just added unit test in Camel 2.0 that looks like you route and it
>>>> works:
>>>> http://svn.apache.org/viewvc?view=rev&revision=771312
>>>>
>>>> What version of Camel are you using?
>>>>
>>>> The reason could be the body message is null, as the timer does not
>>>> create any input message.
>>>> There was such a bug in Camel 1.3/1.4 when using the tracer.
>>>>
>>>> You can try adding
>>>> .setBody(constant(""))
>>>>
>>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Timer-endpoint-and-errorHandler-tp23366970p23371453.html
>>> Sent from the Camel - Users (activemq) mailing list archive at
>>> Nabble.com.
>>>
>>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>> Apache Camel Reference Card:
>> http://refcardz.dzone.com/refcardz/enterprise-integration
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Timer endpoint and errorHandler

Claus Ibsen-2
Hi

Could you create a .zip with a sample project that shows the problem?
And create a JIRA ticket and attach the file there?
http://camel.apache.org/support.html

Then we have a project to use to dig into the matter. Much appreciated.



On Tue, May 5, 2009 at 7:46 AM, arhan <[hidden email]> wrote:

>
> Willem, sure! Here it is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xsi:schemaLocation="
>       http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>       http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd">
>
>  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>    <package>my.timer</package>
>  </camelContext>
>
> </beans>
>
> The route builder actually resides in my.timer package.
>
>
>
> willem.jiang wrote:
>>
>> Hi,
>>
>> Can you also show us the "config.xml", it will help us to find the key
>> of this issue.
>>
>> Willem
>>
>> arhan wrote:
>>> Seems that I found the difference, but have no solution yet.
>>>
>>> Sorry, I wasn't specific enough at first.
>>>
>>> Instead of starting the app using org.apache.camel.spring.Main class, I'm
>>> starting it just using the Spring context:
>>>
>>> public class App {
>>>   public static void main(String[] args) {
>>>     new ClassPathXmlApplicationContext("config.xml").start();
>>>   }
>>> }
>>>
>>> And the route class:
>>>
>>> public class Route extends SpringRouteBuilder {
>>>   public void configure() throws Exception {
>>>     onException(RuntimeCamelException.class);
>>>     errorHandler(loggingErrorHandler(getClass().getName()));
>>>
>>> from("timer:hello?daemon=true&period=2000").to("log:myLogger?level=INFO");
>>>   }
>>> }
>>>
>>> The route triggers only once, producing the following output:
>>> May 4, 2009 8:07:56 PM org.apache.camel.impl.DefaultCamelContext doStart
>>> INFO: Apache Camel 2.0-M1 (CamelContext:camel) is starting
>>> May 4, 2009 8:07:57 PM org.apache.camel.impl.DefaultCamelContext doStart
>>> INFO: Apache Camel 2.0-M1 (CamelContext:camel) started
>>> May 4, 2009 8:07:57 PM org.apache.camel.processor.Logger process
>>> INFO: Exchange[BodyType:null, Body:null]
>>>
>>>
>>> This is with 2.0-M1. Will try the SNAPSHOT version a bit later.
>>>
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>> On Mon, May 4, 2009 at 6:06 PM, arhan <[hidden email]> wrote:
>>>>> Hi!
>>>>>
>>>>> I tried it with 2.0-M1
>>>> Well I am surprised. The unit test I added is 2.0-SNAPSHOT.
>>>>
>>>> How do you start/run Camel? Could be something there. And what is
>>>> logged in the output when you say it "hangs"?
>>>> And how have you defined your bean?
>>>>
>>>> You can also try out the SNAPSHOT version. A m2 is scheduled to be
>>>> build and released soon. The person doing this is however a bit tight
>>>> work other work.
>>>> But there is a topic on the camel dev forum about that release being
>>>> in progress.
>>>>
>>>> The snapshot can be downloaded and/or use maven. See this page:
>>>> http://camel.apache.org/download.html
>>>>
>>>>>
>>>>> Claus Ibsen-2 wrote:
>>>>>>
>>>>>> I just added unit test in Camel 2.0 that looks like you route and it
>>>>>> works:
>>>>>> http://svn.apache.org/viewvc?view=rev&revision=771312
>>>>>>
>>>>>> What version of Camel are you using?
>>>>>>
>>>>>> The reason could be the body message is null, as the timer does not
>>>>>> create any input message.
>>>>>> There was such a bug in Camel 1.3/1.4 when using the tracer.
>>>>>>
>>>>>> You can try adding
>>>>>> .setBody(constant(""))
>>>>>>
>>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Timer-endpoint-and-errorHandler-tp23366970p23371453.html
>>>>> Sent from the Camel - Users (activemq) mailing list archive at
>>>>> Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Open Source Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>> Apache Camel Reference Card:
>>>> http://refcardz.dzone.com/refcardz/enterprise-integration
>>>>
>>>>
>>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Timer-endpoint-and-errorHandler-tp23366970p23381372.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration
Interview with me:
http://architects.dzone.com/articles/interview-claus-ibsen-about?mz=7893-progress