Hi

Yeah if you keep it plain camel and not fancy spring boot stuff

On Thu, Mar 21, 2024 at 11:06 AM Mikael Andersson Wigander
<mikael.andersson.wigan...@pm.me.invalid> wrote:

> Spring boot OK?
>
> /M
>
> Den 21 mars 2024 kl 10:51, Claus Ibsen <[claus.ib...@gmail.com](mailto:Den
> 21 mars 2024 kl 10:51, Claus Ibsen <<a href=)> skrev:
>
> > Hi
> >
> > Can you make something that is pure camel (not quarkus) that will help
> >
> > On Thu, Mar 21, 2024 at 7:56 AM Mikael Andersson Wigander
> > <mikael.andersson.wigan...@pm.me.invalid> wrote:
> >
> >> Here's a repo to use
> >>
> >> https://github.com/hakuseki/code-with-quarkus
> >>
> >>
> >>
> >>
> >> /M
> >>
> >>
> >> On Wednesday, March 20th, 2024 at 22:17, Claus Ibsen <
> >> claus.ib...@gmail.com> wrote:
> >>
> >> > Hi
> >> >
> >> > Are you able to put together a smaller and simpler example with just
> >> routes
> >> > (no rest-dsl) that can let us quicker take a look and better
> understand
> >> > what is happening?
> >> >
> >> >
> >> > On Mon, Mar 18, 2024 at 10:04 AM Mikael Andersson Wigander
> >> > mikael.andersson.wigan...@pm.me.invalid wrote:
> >> >
> >> > > Hi
> >> > >
> >> > > I have experienced a weird behavior in Camel 4.4.0 in Quarkus where
> the
> >> > > Exception handling is not executing as expected when using a toV().
> >> > >
> >> > > In my code sample below everything starts with a rest call.
> >> > > If this rest call finish without errors then the original message
> >> should
> >> > > be returned.
> >> > > If an error is thrown, then an error message should be returned.
> >> > >
> >> > > But if I call an endpoint using the .toV(), the error is processed
> as
> >> > > expected BUT NOT returned. It seems like something is messing with
> the
> >> unit
> >> > > of work or whatever…
> >> > >
> >> > > from(direct("start"))
> >> > > .setBody(constant(List.of("A", "B")))
> >> > > .to(direct("line"));
> >> > >
> >> > > // .toV(direct("line").getUri(), "mySend", "myReceive");
> >> > >
> >> > > By commenting out the .to() and removing the comment on .toV() the
> >> problem
> >> > > occurs.
> >> > >
> >> > > This is a simulation so the incoming rest post payload is NOT
> returned
> >> > > (just POST a JSON), however the body of the "start" endpoint should
> be
> >> > > returned if everything work, but an error message should be returned
> >> if an
> >> > > error is thrown.
> >> > > This is not happening if the .toV() is used. Then the body of the
> >> "start"
> >> > > endpoint is returned.
> >> > >
> >> > > Might this be a bug or have I messed something up?
> >> > >
> >> > > I really like the Variables now, to send to an endpoint and be
> certain
> >> the
> >> > > original body is untouched without the hazzle of storing/restoring
> >> logic…
> >> > >
> >> > >
> >> > > /M
> >> > >
> >> > > *public class *TestRouter *extends *EndpointRouteBuilder {
> >> > > @Override
> >> > > *public void *configure() *throws Exception {
> >> > > onException(IllegalAccessException.class)
> >> > > .routeId("Exceptions")
> >> > > .maximumRedeliveries(0)
> >> > > .handled(true)
> >> > > .removeHeaders("")
> >> > > .process(*new *JsonResponseProcessor())
> >> > > .to(log("Exceptions").level("WARN")
> >> > > .showBody(false)
> >> > > .showBodyType(false)
> >> > > .showHeaders(true)
> >> > > .multiline(true))
> >> > > .to(direct("reply"));
> >> > >
> >> > > restConfiguration()
> >> > > .bindingMode(RestBindingMode.json)
> >> > > .dataFormatProperty("prettyPrint", "true")
> >> > > .component("servlet")
> >> > > .apiProperty("cors", "true");
> >> > >
> >> > > rest().post("/test")
> >> > > .id("REST-workOrder-POST")
> >> > > .consumes("application/json")
> >> > > .produces("application/json")
> >> > > .outType(ResponseMessage.class)
> >> > > .to(direct("start").getUri());
> >> > >
> >> > > from(direct("start"))
> >> > > .setBody(constant(List.of("A", "B")))
> >> > > .to(direct("line"));
> >> > >
> >> > > *// .toV(direct("line").getUri(), "mySend", "myReceive");
> >> > > *from("direct:line")
> >> > > .to("log:line")
> >> > > .process(*new *MyProcessor())
> >> > > .to("mock:line");
> >> > >
> >> > > from(direct("reply"))
> >> > > .routeId("createResponse")
> >> > > .description("Creates a unified response")
> >> > > .to(log("DIRECT_REPLY").showBody(true)
> >> > > .showVariables(true)
> >> > > .showBodyType(true)
> >> > > .showHeaders(true)
> >> > > .multiline(true))
> >> > > .end();
> >> > > }
> >> > >
> >> > > *private class *MyProcessor *implements
> *org.apache.camel.*Processor *
> >> > > {
> >> > > @Override
> >> > > *public void *process(*final **Exchange *exchange) *throws
> *Exception
> >> > > {
> >> > > log.info(exchange.getIn()
> >> > > .getBody(String.class));
> >> > > *throw new *IllegalAccessException("Error occurred");
> >> > > }
> >> > > }
> >> > >
> >> > > *private class *JsonResponseProcessor *implements **Processor *{
> >> > > @Override
> >> > > *public void *process(*final **Exchange *exchange) {
> >> > >
> >> > > Exception cause = exchange.getProperty(Exchange.
> >> > > EXCEPTION_CAUGHT, Exception.class);
> >> > > ResponseMessage message = *new *ResponseMessage();
> >> > >
> >> > > *final **Message *in = exchange.getIn();
> >> > > *if *(cause != null) {
> >> > > String responseCode = in.getHeader(Exchange.
> >> > > HTTP_RESPONSE_CODE, String.class);
> >> > >
> >> > > String reason = "Unspecific Error";
> >> > > String errorString = cause.getMessage();
> >> > > String statusCode = "1000";
> >> > >
> >> > > in.setHeader(Exchange.HTTP_RESPONSE_CODE,
> >> > > HttpResponseStatus.INTERNAL_SERVER_ERROR);
> >> > > message.setError(NumberUtils.toInt(statusCode, 1000),
> >> > > String.format("ERROR message = %s(%s)",
> >> > > reason, errorString));
> >> > >
> >> > > }
> >> > > in.setBody(message);
> >> > > }
> >> > > }
> >> > > }
> >> > >
> >> > > ------------------------------
> >> > >
> >> > > Capgemini is a trading name used by the Capgemini Group of companies
> >> which
> >> > > includes Capgemini Sverige AB, a company registered in Sweden
> (number
> >> > > 556092-3053) whose registered office is at FLEMINGGATAN 18 BOX 12054
> >> S-102
> >> > > 22 Stockholm, Sweden.
> >> > > This message contains information that may be privileged or
> >> confidential
> >> > > and is the property of the Capgemini Group. It is intended only for
> the
> >> > > person to whom it is addressed. If you are not the intended
> recipient,
> >> you
> >> > > are not authorized to read, print, retain, copy, disseminate,
> >> distribute,
> >> > > or use this message or any part thereof. If you receive this
> message in
> >> > > error, please notify the sender immediately and delete all copies of
> >> this
> >> > > message.
> >> >
> >> >
> >> > --
> >> > Claus Ibsen
> >> > -----------------
> >> > @davsclaus
> >> > Camel in Action 2: https://www.manning.com/ibsen2
> >>
> >
> > --
> > Claus Ibsen
> > -----------------
> > @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to