camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lleclerc <>
Subject Problem with isUseAdviceWith() and Intercept.
Date Thu, 29 Nov 2012 17:45:45 GMT

I am trying to intercept a message to skip the Http request and proceed with
my route.
Here is the class you can copy/paste to try it out.

Return false in isUseAdviceWith() : The test is success but the message is
never intercepted.

Return true in isUseAdviceWith() : I get this exception :
org.apache.camel.FailedToCreateRouteException: Failed to create route route1
at: >>> To[http4://] <<< in route:
Route[[From[direct:myDirect]] -> [To[http4://stackoverflow.c... because of
Failed to resolve endpoint: http4:// due to: null

Using camel-test, camel-core, camel-http4 2.10.2 and httpclient-osgi,
httpcore-osgi 4.2.2

Here is the code :

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.AdviceWithRouteBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.http4.HttpComponent;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

public class IsUseAdviceWithJUnit4Test extends CamelTestSupport {

    private String providerEndPointURI = "http4://";
    private String timerEndPointURI = "timer://myTimer";
    private String mockEndPointURI = "mock:myMock";
    private String directEndPointURI = "direct:myDirect";

    public void testIsUseAdviceWith() throws Exception {

        context.getRouteDefinitions().get(0).adviceWith(context, new
AdviceWithRouteBuilder() {
            public void configure() throws Exception {



                        .process(new Processor() {
                            public void process(Exchange exchange) throws
Exception {

        // we must manually start when we are done with all the advice with


        template.sendBody(directEndPointURI, "a trigger");


        assertNotNull(context.hasEndpoint("mock:" + directEndPointURI));


    public boolean isUseAdviceWith() {
        return true;

    public boolean isUseRouteBuilder() {
        return true;

    protected RouteBuilder createRouteBuilder() throws Exception {

        return new RouteBuilder() {
            public void configure() throws Exception {

                from(timerEndPointURI +

Thanks !

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message