I'm trying to replace a REST DSL "from" Endpoint using adviceWith and
replaceFromWith appears to be failing because Camel is appending a routeId
parameter to the end of the direct URI.

Any suggestions on how to fix this? I've included below a sample Test class
illustrating the issue as well as the failure.

######################################################
# Test Program
######################################################

package com.theperducogroup;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.builder.AdviceWithRouteBuilder;
import org.apache.camel.model.RouteDefinition;
import org.apache.camel.test.junit4.CamelTestSupport;

import org.junit.Test;

public class RestfulRouteTest extends CamelTestSupport
{
    @Test
    public void doSomething()
    {
        try
        {
            context.getRouteDefinition("test").adviceWith(context, new
AdviceWithRouteBuilder()
            {
                public void configure()
                {
                    replaceFromWith("direct:test");
                }
            });
        }
        catch (Exception e)
        {
            System.out.println(e);
        }
    }

    @Override
    protected RouteBuilder createRouteBuilder()
    {
        return new RouteBuilder()
        {
            public void configure()
            {
                restConfiguration()
                    .component("undertow");

                rest("/test").post().route()
                    .routeId("test")
                    .to("direct:out")
                    .endRest();
            }
        };
    }
}

######################################################
# Exception
######################################################

org.apache.camel.FailedToCreateRouteException: Failed to create route test:
Route(test)[[From[direct://test?routeId=test]] -> [To[direct... because of
Failed to resolve endpoint: direct://test?routeId=test due to: Failed to
resolve endpoint: direct://test?routeId=test due to: There are 1 parameters
that couldn't be set on the endpoint. Check the uri if the parameters are
spelt correctly and that they are properties of the endpoint. Unknown
parameters=[{routeId=test}]

Reply via email to