Awesome! Thanks Claus!

On Thu, Dec 20, 2018 at 5:38 PM Claus Ibsen <claus.ib...@gmail.com> wrote:

> On Thu, Dec 20, 2018 at 11:34 PM Bradford Fisher
> <bradf...@bradfordfisher.com> wrote:
> >
> > Hey Claus,
> >
> > Thanks for responding! I was actually just considering routing the REST
> DSL
> > Endpoints directly to the "direct" endpoint and then testing from the
> > direct Endpoint onward.
> >
> > Just to clarify, you are suggesting something similar to:
> >
> > rest("/test")
> >     .post()
> >     .route()
> >     .to("direct:process")
> >     .endRest();
> >
> > from("direct:process")
> >     .process(testProcessor)
> >     .to("direct:out");
> >
> > Where "direct:process" would be the start of any real processing and thus
> > what ought to be tested?
> >
>
> Yeah its good practice to separate rest-dsl from the regular Camel
> routes and link them via the direct endpoint.
> In your rest-dsl above you can also omit the route, as there is a
> shortcut where you can just use to or toD to call another route asap.
>
>
>
> > On Thu, Dec 20, 2018 at 5:18 PM Claus Ibsen <claus.ib...@gmail.com>
> wrote:
> >
> > > 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
> > >
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Reply via email to