So what you should/can advice is the route that you are calling via direct, eg the route that you may have the starts from direct:out
On Thu, Dec 20, 2018 at 11:13 PM Claus Ibsen <claus.ib...@gmail.com> wrote: > > Hi > > The advice with functionality is for regular Camel routes, eg they > start via from() > So what you do is not supported. > > On Thu, Dec 20, 2018 at 10:15 PM Bradford Fisher > <bradf...@bradfordfisher.com> wrote: > > > > 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}] > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2