schema validation

2024-03-20 Thread Mitch Trachtenberg
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: Issue with unit or work and toV endpoint when Excetion thrown

2024-03-20 Thread Claus Ibsen
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
 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));
>
> }
> 

Announcing the Community Over Code 2024 Streaming Track

2024-03-20 Thread James Hughes
Hi all,

Community Over Code , the ASF conference,
will be held in Denver, Colorado,

October 7-10, 2024. The call for presentations

is open now through April 15, 2024.  (This is two months earlier than last
year!)

I am one of the co-chairs for the stream processing track, and we would
love to see you there and hope that you will consider submitting a talk.

About the Streaming track:

There are many top-level ASF projects which focus on and push the envelope
for stream and event processing.  ActiveMQ, Beam, Bookkeeper, Camel, Flink,
Kafka, Pulsar, RocketMQ, and Spark are all house-hold names in the stream
processing and analytics world at this point.  These projects show that
stream processing has unique characteristics requiring deep expertise.  On
the other hand, users need easy to apply solutions.  The streaming track
will host talks focused on the use cases and advances of these projects as
well as other developments in the streaming world.

Thanks and see you in October!

Jim


Svar: Camel Quarkus native missing classes

2024-03-20 Thread Mikael Andersson Wigander
I did what’s stated in the documentation and it is working fine.

Just curious why it suddenly tipped over and broke…

/M

Den 20 mars 2024 kl 13:03, Mikael Andersson Wigander 
<[mikael.andersson.wigan...@pm.me.INVALID](mailto:Den 20 mars 2024 kl 13:03, 
Mikael Andersson Wigander < skrev:

> I have an application that is built and run as native.
> It has been running fine for a while but then I make to me a small 
> insignificant change it breaks.
>
> It throws a runtime exception complaining
> ClassNotFoundException.
>
> This class has been there all time and the change I made was made elsewhere.
>
> I haven’t registered any of my classes for reflection, some has @Unremovable.
> If I add @RegisterForReflection to the mentioned class the next exception is 
> thrown.
> Same error but for a class generated by JAXB maven plugin.
>
> Any advice?
>
> I can annotate my own classes but not generated ones.
>
> I use Quarkus 3.8.2 and also tested 3.8.3 with the same symptoms.
>
> /M

Camel Quarkus native missing classes

2024-03-20 Thread Mikael Andersson Wigander
I have an application that is built and run as native.
It has been running fine for a while but then I make to me a small 
insignificant change it breaks.

It throws a runtime exception complaining
ClassNotFoundException.

This class has been there all time and the change I made was made elsewhere.

I haven’t registered any of my classes for reflection, some has @Unremovable.
If I add @RegisterForReflection to the mentioned class the next exception is 
thrown.
Same error but for a class generated by JAXB maven plugin.

Any advice?

I can annotate my own classes but not generated ones.

I use Quarkus 3.8.2 and also tested 3.8.3 with the same symptoms.

/M