Re: Camel Jbang 4.4.1 not available?

2024-03-21 Thread Tadayoshi Sato
Ah Claus already did it. Thanks Claus :-)

On Fri, Mar 22, 2024 at 2:29 PM Tadayoshi Sato 
wrote:

> Hi,
>
> The Camel JBang command looks at this file in the default branch.
>
> https://github.com/apache/camel/blob/main/dsl/camel-jbang/camel-jbang-main/dist/CamelJBang.java#L22-L24
>
> As you see, it still points to 4.4.0. Someone will soon update it to 4.4.1
> and you should be able to use it.
>
> By the way, the latest JBang version allows us to pass additional system
> properties at `jbang app install`, so you can as well now do this to
> install a specific version of Camel JBang command:
>
>   $ jbang app install -Dcamel.jbang.version=4.4.1 camel@apache/camel
>
> Hope it helps,
>
> On Fri, Mar 22, 2024 at 2:10 PM Mikael Koskinen 
> wrote:
>
>> Hi,
>>
>> I'm trying to install Camel Jbang 4.4.1 but the 4.4.0 always gets
>> installed. --Force and --fresh parameters don't help.
>>
>> jbang app install --force --fresh camel@apache/camel
>>
>> I checked the CamelJBang.java and it still seems to refer to 4.4.0, is
>> this
>> something that needs to be changed on the source code side?
>>
>> I'm not actually that familiar with how the versioning with the Camel
>> Jbang
>> works. I assumed that the release of Camel 4.4.1 means that the Camel
>> Jbang
>> is also updated to the same version. But now I noticed that there's no
>> 4.4.1 release for the docker image either, so I assume they have a
>> different release cadence.
>>
>> Specifying the exact version when running a command works, for example:
>>
>> jbang --fresh "-Dcamel.jbang.version=4.4.1" camel@apache/camel --version
>>
>> Best regards,
>> Mikael
>>
>
>
> --
> Tadayoshi Sato
>


-- 
Tadayoshi Sato


Re: Camel Jbang 4.4.1 not available?

2024-03-21 Thread Tadayoshi Sato
Hi,

The Camel JBang command looks at this file in the default branch.
https://github.com/apache/camel/blob/main/dsl/camel-jbang/camel-jbang-main/dist/CamelJBang.java#L22-L24

As you see, it still points to 4.4.0. Someone will soon update it to 4.4.1
and you should be able to use it.

By the way, the latest JBang version allows us to pass additional system
properties at `jbang app install`, so you can as well now do this to
install a specific version of Camel JBang command:

  $ jbang app install -Dcamel.jbang.version=4.4.1 camel@apache/camel

Hope it helps,

On Fri, Mar 22, 2024 at 2:10 PM Mikael Koskinen  wrote:

> Hi,
>
> I'm trying to install Camel Jbang 4.4.1 but the 4.4.0 always gets
> installed. --Force and --fresh parameters don't help.
>
> jbang app install --force --fresh camel@apache/camel
>
> I checked the CamelJBang.java and it still seems to refer to 4.4.0, is this
> something that needs to be changed on the source code side?
>
> I'm not actually that familiar with how the versioning with the Camel Jbang
> works. I assumed that the release of Camel 4.4.1 means that the Camel Jbang
> is also updated to the same version. But now I noticed that there's no
> 4.4.1 release for the docker image either, so I assume they have a
> different release cadence.
>
> Specifying the exact version when running a command works, for example:
>
> jbang --fresh "-Dcamel.jbang.version=4.4.1" camel@apache/camel --version
>
> Best regards,
> Mikael
>


-- 
Tadayoshi Sato


Camel Jbang 4.4.1 not available?

2024-03-21 Thread Mikael Koskinen
Hi,

I'm trying to install Camel Jbang 4.4.1 but the 4.4.0 always gets
installed. --Force and --fresh parameters don't help.

jbang app install --force --fresh camel@apache/camel

I checked the CamelJBang.java and it still seems to refer to 4.4.0, is this
something that needs to be changed on the source code side?

I'm not actually that familiar with how the versioning with the Camel Jbang
works. I assumed that the release of Camel 4.4.1 means that the Camel Jbang
is also updated to the same version. But now I noticed that there's no
4.4.1 release for the docker image either, so I assume they have a
different release cadence.

Specifying the exact version when running a command works, for example:

jbang --fresh "-Dcamel.jbang.version=4.4.1" camel@apache/camel --version

Best regards,
Mikael


Re: schema validation

2024-03-21 Thread Mitch Trachtenberg
Thanks, Federico.  I've been working from an increasingly modified example
program, so I'll try checking from scratch.

Apologies to the board for not having done that prior to raising my
question about this issue.

Thanks,
Mitch

On Thu, Mar 21, 2024 at 6:49 AM Federico Mariani <
federico.mariani.1...@gmail.com> wrote:

> Hello,
>
> I just generated a camel spring boot application with the archetype and
> added the CamelValidationConfig class, but it is working as expected, I can
> see the bean being created without NoClassDefFoundError. I am afraid you
> are mixing different camel versions. can you try starting fresh using the
> archetype? for example, *mvn archetype:generate
> -DarchetypeGroupId=org.apache.camel.archetypes
> -DarchetypeArtifactId=camel-archetype-spring-boot -DarchetypeVersion=4.4.0
> *
>
> Greetings,
> Federico
>
> Il giorno gio 21 mar 2024 alle ore 01:01 Mitch Trachtenberg <
> mjt...@gmail.com> ha scritto:
>
> > Good day all,
> >
> > I'm at a loss as to running schema validation in 4.3.0.  I tried (with
> > Gemini's help) adding a file like that below; notice that the
> > ValidatingProcessor is defined in
> > org.apache.camel.support.processor.validation.ValidatingProcessor:
> >
> > import org.apache.camel.CamelContext;
> > import org.apache.camel.support.processor.validation.ValidatingProcessor;
> > import org.springframework.beans.factory.annotation.Autowired;
> > import org.springframework.context.annotation.Bean;
> > import org.springframework.context.annotation.Configuration;
> > import java.io.File;
> >
> > @Configuration
> > public class CamelValidationConfig {
> >
> > @Autowired
> > private CamelContext camelContext;
> >
> > @Bean
> > public ValidatingProcessor validatingProcessor() {
> > ValidatingProcessor processor = new ValidatingProcessor();
> > // Configure XSD schema as needed (see variations in the route
> > section below)
> > File schemaFile = new File("classpath:order.xsd");
> > processor.setSchemaFile(schemaFile);
> >
> > return processor;
> > }
> > }
> >
> > But when I add camel-validator to my pom, I get a complaint:
> > Exception in thread "main" java.lang.IllegalStateException:
> > java.lang.NoClassDefFoundError:
> > org/apache/camel/support/SingleInputLanguageSupport
> >
> > Any suggestions?  I've tried adding camel-support, but I really have no
> > idea what to add.  This is 4.3.0 with spring boot.
> >
> > Thanks for any suggestions,
> > Mitch
> >
>


Re: schema validation

2024-03-21 Thread Federico Mariani
Hello,

I just generated a camel spring boot application with the archetype and
added the CamelValidationConfig class, but it is working as expected, I can
see the bean being created without NoClassDefFoundError. I am afraid you
are mixing different camel versions. can you try starting fresh using the
archetype? for example, *mvn archetype:generate
-DarchetypeGroupId=org.apache.camel.archetypes
-DarchetypeArtifactId=camel-archetype-spring-boot -DarchetypeVersion=4.4.0 *

Greetings,
Federico

Il giorno gio 21 mar 2024 alle ore 01:01 Mitch Trachtenberg <
mjt...@gmail.com> ha scritto:

> Good day all,
>
> I'm at a loss as to running schema validation in 4.3.0.  I tried (with
> Gemini's help) adding a file like that below; notice that the
> ValidatingProcessor is defined in
> org.apache.camel.support.processor.validation.ValidatingProcessor:
>
> import org.apache.camel.CamelContext;
> import org.apache.camel.support.processor.validation.ValidatingProcessor;
> import org.springframework.beans.factory.annotation.Autowired;
> import org.springframework.context.annotation.Bean;
> import org.springframework.context.annotation.Configuration;
> import java.io.File;
>
> @Configuration
> public class CamelValidationConfig {
>
> @Autowired
> private CamelContext camelContext;
>
> @Bean
> public ValidatingProcessor validatingProcessor() {
> ValidatingProcessor processor = new ValidatingProcessor();
> // Configure XSD schema as needed (see variations in the route
> section below)
> File schemaFile = new File("classpath:order.xsd");
> processor.setSchemaFile(schemaFile);
>
> return processor;
> }
> }
>
> But when I add camel-validator to my pom, I get a complaint:
> Exception in thread "main" java.lang.IllegalStateException:
> java.lang.NoClassDefFoundError:
> org/apache/camel/support/SingleInputLanguageSupport
>
> Any suggestions?  I've tried adding camel-support, but I really have no
> idea what to add.  This is 4.3.0 with spring boot.
>
> Thanks for any suggestions,
> Mitch
>


Re: Svar: Re: Issue with unit or work and toV endpoint when Excetion thrown

2024-03-21 Thread Mikael Andersson Wigander


Hi

As simple as I get do it…

https://github.com/hakuseki/demo-Camel-UoW



/M


On Thursday, March 21st, 2024 at 11:09, Claus Ibsen  
wrote:

> 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 < 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();
> > 

Re: Svar: Re: Issue with unit or work and toV endpoint when Excetion thrown

2024-03-21 Thread Claus Ibsen
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
 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 < 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
> >  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 

Svar: Re: Issue with unit or work and toV endpoint when Excetion thrown

2024-03-21 Thread Mikael Andersson Wigander
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 < 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
>  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);
>> > > 

Re: Issue with unit or work and toV endpoint when Excetion thrown

2024-03-21 Thread Claus Ibsen
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
 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 

Re: Issue with unit or work and toV endpoint when Excetion thrown

2024-03-21 Thread Mikael Andersson Wigander
Here's a repo to use

https://github.com/hakuseki/code-with-quarkus




/M


On Wednesday, March 20th, 2024 at 22:17, Claus Ibsen  
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,