RouteBuilder: Problems with onException and id

View: New views
7 Messages — Rating Filter:   Alert me  

RouteBuilder: Problems with onException and id

by DulmerLucsly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi erverybody,

i have a little problem with exceptionhandling.
Since i'm new to activeMq/Camel sorry if the question is trivial...

I try to build a route with java DSL. My route looks like this:

....
public void configure() {

from("jms:fileIn?transacted=true")
  .onException(UnmarshalException.class)
   .handled(true)
    .bean(FileProcessExceptionBean.class,"handleException")
.end()
.id("fileMapping")
.transacted()
.process(new FileProcessor())
.to("jms:fileOut");

}

My problem is that in jConsole my Route is labeled "Route1" ( resp. Route2, Route3 etc).
When i remove the onExecption-section my route gets labeled correctly like with .id() specified.
When I move the onException-section to after .transcated(true) then the route gets labeled correctly, but the onException-section will ALWAYS be run, even if there was no Exception thrown.

Any ideas ?

GeneralInfo:
Apache Camel 2.1-SNAPSHOT (build 20091022) , Java 1.6.0,  Linux

Re: RouteBuilder: Problems with onException and id

by Claus Ibsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 23, 2009 at 1:55 PM, DulmerLucsly
<dulmer.lucsly.nabble@...> wrote:

>
> Hi erverybody,
>
> i have a little problem with exceptionhandling.
> Since i'm new to activeMq/Camel sorry if the question is trivial...
>
> I try to build a route with java DSL. My route looks like this:
>
> ....
> public void configure() {
>
> from("jms:fileIn?transacted=true")
>  .onException(UnmarshalException.class)
>   .handled(true)
>    .bean(FileProcessExceptionBean.class,"handleException")
> .end()
> .id("fileMapping")
> .transacted()
> .process(new FileProcessor())
> .to("jms:fileOut");
>
> }
>
> My problem is that in jConsole my Route is labeled "Route1" ( resp. Route2,
> Route3 etc).
> When i remove the onExecption-section my route gets labeled correctly like
> with .id() specified.
> When I move the onException-section to after .transcated(true) then the
> route gets labeled correctly, but the onException-section will ALWAYS be
> run, even if there was no Exception thrown.
>
> Any ideas ?
>

Yeah the ID has not really had much attention. In Spring XML its not a
problem as its the id attribute on the XML tag itself.
However in Java DSL its a method call and the java language is not
well suited for DSL like syntax.

I wonder if we should either force people to use
route("myRouteId).from(xxxx)...

Or offer an option on the from endpoint, something like routeId
from("xxxx?routeId=myCoolRoute").onException()....

The latter have the advantage at it works with multiple from's




> GeneralInfo:
> Apache Camel 2.1-SNAPSHOT (build 20091022) , Java 1.6.0,  Linux
>
> --
> View this message in context: http://www.nabble.com/RouteBuilder%3A-Problems-with-onException-and-id-tp26024958p26024958.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: RouteBuilder: Problems with onException and id

by DRy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

having a user defined id is very important if you plan to use JMX-based administration (done by non-developers "dummies") for your application (as I/we do). We must be able to identify and start/stop routes via call to JMX or JConsole.

I would prefer the "route(...)" solution ... but does that means that you have to start every route this way? Will this be mandatory .. ?

Is there a way to fix (or workaround) this problem asap ... ?
 

Claus Ibsen-2 wrote:
On Fri, Oct 23, 2009 at 1:55 PM, DulmerLucsly
<dulmer.lucsly.nabble@quantentunnel.de> wrote:
>
> Hi erverybody,
>
> i have a little problem with exceptionhandling.
> Since i'm new to activeMq/Camel sorry if the question is trivial...
>
> I try to build a route with java DSL. My route looks like this:
>
> ....
> public void configure() {
>
> from("jms:fileIn?transacted=true")
>  .onException(UnmarshalException.class)
>   .handled(true)
>    .bean(FileProcessExceptionBean.class,"handleException")
> .end()
> .id("fileMapping")
> .transacted()
> .process(new FileProcessor())
> .to("jms:fileOut");
>
> }
>
> My problem is that in jConsole my Route is labeled "Route1" ( resp. Route2,
> Route3 etc).
> When i remove the onExecption-section my route gets labeled correctly like
> with .id() specified.
> When I move the onException-section to after .transcated(true) then the
> route gets labeled correctly, but the onException-section will ALWAYS be
> run, even if there was no Exception thrown.
>
> Any ideas ?
>

Yeah the ID has not really had much attention. In Spring XML its not a
problem as its the id attribute on the XML tag itself.
However in Java DSL its a method call and the java language is not
well suited for DSL like syntax.

I wonder if we should either force people to use
route("myRouteId).from(xxxx)...

Or offer an option on the from endpoint, something like routeId
from("xxxx?routeId=myCoolRoute").onException()....

The latter have the advantage at it works with multiple from's




> GeneralInfo:
> Apache Camel 2.1-SNAPSHOT (build 20091022) , Java 1.6.0,  Linux
>
> --
> View this message in context: http://www.nabble.com/RouteBuilder%3A-Problems-with-onException-and-id-tp26024958p26024958.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: RouteBuilder: Problems with onException and id

by Claus Ibsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 26, 2009 at 9:20 AM, DRy <dirk.rybinski@...> wrote:

>
> Hi,
>
> having a user defined id is very important if you plan to use JMX-based
> administration (done by non-developers "dummies") for your application (as
> I/we do). We must be able to identify and start/stop routes via call to JMX
> or JConsole.
>
> I would prefer the "route(...)" solution ... but does that means that you
> have to start every route this way? Will this be mandatory .. ?
No only if you want to specify the route id you need to do this extra

route("myCoolRoute").from("xxx")....


>
> Is there a way to fix (or workaround) this problem asap ... ?
>

The Spring DSL works with route id

Using the Camel API you should be able to patch this from Java DSL.
Give me some time to check upon it, working on another ticket at this moment.

But could you create a JIRA ticket for this issue? Then we wont forget
and can have it in 2.1


>
>
> Claus Ibsen-2 wrote:
>>
>> On Fri, Oct 23, 2009 at 1:55 PM, DulmerLucsly
>> <dulmer.lucsly.nabble@...> wrote:
>>>
>>> Hi erverybody,
>>>
>>> i have a little problem with exceptionhandling.
>>> Since i'm new to activeMq/Camel sorry if the question is trivial...
>>>
>>> I try to build a route with java DSL. My route looks like this:
>>>
>>> ....
>>> public void configure() {
>>>
>>> from("jms:fileIn?transacted=true")
>>>  .onException(UnmarshalException.class)
>>>   .handled(true)
>>>    .bean(FileProcessExceptionBean.class,"handleException")
>>> .end()
>>> .id("fileMapping")
>>> .transacted()
>>> .process(new FileProcessor())
>>> .to("jms:fileOut");
>>>
>>> }
>>>
>>> My problem is that in jConsole my Route is labeled "Route1" ( resp.
>>> Route2,
>>> Route3 etc).
>>> When i remove the onExecption-section my route gets labeled correctly
>>> like
>>> with .id() specified.
>>> When I move the onException-section to after .transcated(true) then the
>>> route gets labeled correctly, but the onException-section will ALWAYS be
>>> run, even if there was no Exception thrown.
>>>
>>> Any ideas ?
>>>
>>
>> Yeah the ID has not really had much attention. In Spring XML its not a
>> problem as its the id attribute on the XML tag itself.
>> However in Java DSL its a method call and the java language is not
>> well suited for DSL like syntax.
>>
>> I wonder if we should either force people to use
>> route("myRouteId).from(xxxx)...
>>
>> Or offer an option on the from endpoint, something like routeId
>> from("xxxx?routeId=myCoolRoute").onException()....
>>
>> The latter have the advantage at it works with multiple from's
>>
>>
>>
>>
>>> GeneralInfo:
>>> Apache Camel 2.1-SNAPSHOT (build 20091022) , Java 1.6.0,  Linux
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/RouteBuilder%3A-Problems-with-onException-and-id-tp26024958p26024958.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://www.nabble.com/RouteBuilder%3A-Problems-with-onException-and-id-tp26024958p26055883.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: RouteBuilder: Problems with onException and id

by DulmerLucsly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I created a JIRA for the id problem

https://issues.apache.org/activemq/browse/CAMEL-2109

What still bothers me is the last sentence. When I rebuild the route and move .id() and .transacted() before onException

public void configure() {

from("jms:fileIn?transacted=true")
 .id("fileMapping")
 .transacted()
  .onException(UnmarshalException.class)
    .handled(true)
    .bean(FileProcessExceptionBean.class,"handleException")
    .end()
 .process(new FileProcessor())
 .to("jms:fileOut");

}

then ALL messages are routed through onException.

Re: RouteBuilder: Problems with onException and id

by DRy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

if I place .onException-part below .id() and .transacted() I got the same problem. But if I place the .onException-part between .id() and .transacted() it work's fine! The exception is handled and the id is set!

So, setting the route-id work's for route-specific onException (in same cases). But setting the route-id in a global onException (defined in the RouteBuilder) does not work ...

... DRy


DulmerLucsly wrote:
I created a JIRA for the id problem

https://issues.apache.org/activemq/browse/CAMEL-2109

What still bothers me is the last sentence. When I rebuild the route and move .id() and .transacted() before onException

public void configure() {

from("jms:fileIn?transacted=true")
 .id("fileMapping")
 .transacted()
  .onException(UnmarshalException.class)
    .handled(true)
    .bean(FileProcessExceptionBean.class,"handleException")
    .end()
 .process(new FileProcessor())
 .to("jms:fileOut");

}

then ALL messages are routed through onException.

Re: RouteBuilder: Problems with onException and id

by Claus Ibsen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Oct 29, 2009 at 10:30 AM, DRy <dirk.rybinski@...> wrote:

>
> Hi,
>
> if I place .onException-part below .id() and .transacted() I got the same
> problem. But if I place the .onException-part between .id() and
> .transacted() it work's fine! The exception is handled and the id is set!
>
> So, setting the route-id work's for route-specific onException (in same
> cases). But setting the route-id in a global onException (defined in the
> RouteBuilder) does not work ...
>
> ... DRy
>

Hi try with latest code and use the new routeId in the DSL instead of id.


>
>
> DulmerLucsly wrote:
>>
>> I created a JIRA for the id problem
>>
>> https://issues.apache.org/activemq/browse/CAMEL-2109
>>
>> What still bothers me is the last sentence. When I rebuild the route and
>> move .id() and .transacted() before onException
>>
>> public void configure() {
>>
>> from("jms:fileIn?transacted=true")
>>  .id("fileMapping")
>>  .transacted()
>>   .onException(UnmarshalException.class)
>>     .handled(true)
>>     .bean(FileProcessExceptionBean.class,"handleException")
>>     .end()
>>  .process(new FileProcessor())
>>  .to("jms:fileOut");
>>
>> }
>>
>> then ALL messages are routed through onException.
>>
>
> --
> View this message in context: http://www.nabble.com/RouteBuilder%3A-Problems-with-onException-and-id-tp26024958p26109780.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus