You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jpalmer1026 <pa...@gmail.com> on 2011/04/11 23:43:12 UTC

Error Handling with Spring XML

I'd like to specify a context-scoped error handler in a Spring XML file to
declare a default error handler. When I configure the handler by using an
errorHandlerRef attribute on the camelContext tag, I'm getting the following
exception when I try to test the handler from a CamelSpringTestSupportClass:

java.lang.IllegalArgumentException: You can not advice with error handlers.
Remove the error handlers from the route builder.

If instead of configuring a context-scoped default error handler, I declare
a route-scoped error handler by using an errorHandlerRef attribute on the
route tag, everything works as expected. 

Is there a reason why I'm unable to configure a default handler by using an
errorHandlerRef attribute on the camelContext tag and then test it from a
CamelSpringTestSupportClass?

Thanks!
 

--
View this message in context: http://camel.465427.n5.nabble.com/Error-Handling-with-Spring-XML-tp4296920p4296920.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Error Handling with Spring XML

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have reproduced the issue and fixed it on trunk
https://issues.apache.org/jira/browse/CAMEL-3877


-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Error Handling with Spring XML

Posted by Claus Ibsen <cl...@gmail.com>.
What Camel and Spring version are you using?



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Error Handling with Spring XML

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Ah you may have encountered an issue. Fell free to log a JIRA ticket.


On Tue, Apr 12, 2011 at 4:17 PM, jpalmer1026 <pa...@gmail.com> wrote:
> Hi Claus,
>
> I'm actually not changing the error handler using adviceWith. My spring
> application context file defines a single error handler, which I reference
> as an attribute on the camelContext tag to make it context-scoped. When I
> subsequently simulate an error using advice with, I get the exception. If I
> modify the application context file and move the error handler ref attribute
> to the route that I am advising, everything works as expected.
>
> My test method that is using adviceWith is as follows:
>
> @Test
> public void testSimulateConnectionError() throws Exception {
>   RouteDefinition route = context.getRouteDefinition("fileSystemToFtp");
>   route.adviceWith(context, new RouteBuilder() {
>      @Override
>      public void configure() throws Exception {
>         interceptSendToEndpoint(sterlingWomsFtpPath)
>            .skipSendToOriginalEndpoint()
>            .process(new SimulateHttpErrorProcessor());
>      }
>   });
>
>        // mocks and assertions
>  }
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Error-Handling-with-Spring-XML-tp4296920p4298303.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Error Handling with Spring XML

Posted by jpalmer1026 <pa...@gmail.com>.
Hi Claus,

I'm actually not changing the error handler using adviceWith. My spring
application context file defines a single error handler, which I reference
as an attribute on the camelContext tag to make it context-scoped. When I
subsequently simulate an error using advice with, I get the exception. If I
modify the application context file and move the error handler ref attribute
to the route that I am advising, everything works as expected.

My test method that is using adviceWith is as follows:

@Test
public void testSimulateConnectionError() throws Exception {
   RouteDefinition route = context.getRouteDefinition("fileSystemToFtp");
   route.adviceWith(context, new RouteBuilder() {
      @Override
      public void configure() throws Exception {
         interceptSendToEndpoint(sterlingWomsFtpPath)
            .skipSendToOriginalEndpoint()
            .process(new SimulateHttpErrorProcessor());
      }
   });
        
        // mocks and assertions
 }      

--
View this message in context: http://camel.465427.n5.nabble.com/Error-Handling-with-Spring-XML-tp4296920p4298303.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Error Handling with Spring XML

Posted by Claus Ibsen <cl...@gmail.com>.
You cannot change error handler using adviceWith as the exception
message tell you.
Its a limitation in the routing engine. We will improve that in Camel
3.0 to make it fully dynamic.



On Mon, Apr 11, 2011 at 11:43 PM, jpalmer1026 <pa...@gmail.com> wrote:
> I'd like to specify a context-scoped error handler in a Spring XML file to
> declare a default error handler. When I configure the handler by using an
> errorHandlerRef attribute on the camelContext tag, I'm getting the following
> exception when I try to test the handler from a CamelSpringTestSupportClass:
>
> java.lang.IllegalArgumentException: You can not advice with error handlers.
> Remove the error handlers from the route builder.
>
> If instead of configuring a context-scoped default error handler, I declare
> a route-scoped error handler by using an errorHandlerRef attribute on the
> route tag, everything works as expected.
>
> Is there a reason why I'm unable to configure a default handler by using an
> errorHandlerRef attribute on the camelContext tag and then test it from a
> CamelSpringTestSupportClass?
>
> Thanks!
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Error-Handling-with-Spring-XML-tp4296920p4296920.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/