Re: [ANNOUNCE] Apache Camel 4.5.0 Released

2024-03-28 Thread Alphonse Bendt
Hi folks,

> Am 28.03.2024 um 12:43 schrieb Gregor Zurowski :
> 
> The Camel PMC is pleased to announce the release of Apache Camel 4.5.0.

just tried out to update one of our projects from 4.4.1 to 4.5.0

(current SpringBoot version, using JUnit5 based tests)

With the update a number of tests start to fail (stacktrace [1]). Are there any 
breaking changes we need to be aware of in the new version? didn’t see anything 
mentioned in the release notes.


[1]
org.apache.camel.FailedToCreateRouteException: Failed to create route XXX: 
Route(XXX)[From[direct:XXX] -> [DoTry[... because of Cannot invoke 
"org.apache.camel.CamelContext.getName()" because "camelContext" is null 
24587 at 
org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:85) 
24588 at 
org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
 
24589 at 
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:728)
 
24590 at 
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:594)
 
24591 at 
org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2391)
 
24592 at org.apache.camel.support.service.BaseService.init(BaseService.java:78) 
24593 at 
org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2027)
 
24594 at 
org.apache.camel.support.service.BaseService.start(BaseService.java:105) 
24595 at 
org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2046)
 
24596 at 
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:212) 
24597 at 
org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:119) 
24598 at 
org.apache.camel.test.spring.junit5.CamelAnnotationsHandler.lambda$handleCamelContextStartup$1(CamelAnnotationsHandler.java:403)
 
24599 at 
org.apache.camel.test.spring.junit5.CamelSpringTestHelper.doToSpringCamelContexts(CamelSpringTestHelper.java:108)
 
24600 at 
org.apache.camel.test.spring.junit5.CamelAnnotationsHandler.handleCamelContextStartup(CamelAnnotationsHandler.java:400)
 
24601 at 
org.apache.camel.test.spring.junit5.CamelSpringBootExecutionListener.beforeTestMethod(CamelSpringBootExecutionListener.java:105)
 
24602 at 
org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:320)
 
24603 at 
org.springframework.test.context.junit.jupiter.SpringExtension.beforeEach(SpringExtension.java:240)
 
24604 at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) 
24605 at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) 
24606Caused by: java.lang.NullPointerException: Cannot invoke 
"org.apache.camel.CamelContext.getName()" because "camelContext" is null 
24607 at 
org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyNamingStrategy.getExchangeStatusTags(MicrometerRoutePolicyNamingStrategy.java:112)
 
24608 at 
org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicy$MetricsStatistics.createCounter(MicrometerRoutePolicy.java:214)
 
24609 at 
org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicy$MetricsStatistics.initAdditionalCounters(MicrometerRoutePolicy.java:94)
 
24610 at 
org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicy$MetricsStatistics.(MicrometerRoutePolicy.java:88)
 
24611 at 
org.apache.camel.component.micrometer.routepolicy.ContextMetricsStatistics.(ContextMetricsStatistics.java:33)
 
24612 at 
org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory.createOrGetContextMetric(MicrometerRoutePolicyFactory.java:115)
 
24613 at 
org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicy.onInit(MicrometerRoutePolicy.java:299)
 
24614 at 
org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:352) 
24615 at 
org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:79) 
24616 ... 18 more

Re: Issue with SpringBootTest and camel-rest

2024-02-19 Thread Alphonse Bendt
hi Federico,

Thanks, that was the missing part!
Thanks to both of you for the support 

For reference:
The rest component can be re-configured to use the same context path as 
previously the camel-servlet:

restConfiguration()
.contextPath(
"/my-api“)

With this i don’t need other changes to my routes.

Alphonse

> Am 19.02.2024 um 10:22 schrieb Federico Mariani 
> :
> 
> Hello, I am getting 404 on the standalone example.
> 
> Beware that OOB camel-servlet and camel-platform-http uses different
> endpoints, camel-servlet */came/** while camel-platform-http */**
> 
> Il giorno dom 18 feb 2024 alle ore 15:09 Alphonse Bendt <
> alphonse.be...@gmail.com> ha scritto:
> 
>> Hi folks,
>> 
>> There is an issue when running tests for a SpringBoot application that
>> uses camel-rest.
>> 
>> When there are multiple tests that use a different configuration (e.g.,
>> different properties), we run into this error:
>> 
>> Caused by:
>>jakarta.servlet.ServletException: Duplicate
>> ServletName detected: CamelServlet. Existing:
>> CamelHttpTransportServlet[name=CamelServlet] This:
>> CamelHttpTransportServlet[name=CamelServlet]. Its advised to use unique
>> ServletName per Camel application.
>>at
>> app//org.apache.camel.component.servlet.CamelHttpTransportServlet.init(CamelHttpTransportServlet.java:68)
>> 
>> 
>> I have created a standalone example to demonstrate the issue:
>> https://github.com/abendt/camel-rest
>> 
>> To reproduce:
>> ./gradlew -i test
>> 
>> The project contains two tests with different configurations (one has an
>> additional active profile).
>> I would expect the build to pass; however, it fails with the mentioned
>> exception.
>> 
>> As a workaround, it's possible to add @DirtiesContext. However, this hurts
>> test performance and should be avoided if possible.
>> 
>> Am i missing something or is this a current limitation of camel-rest?
>> 
>> thanks,
>>   Alphonse



Re: Issue with SpringBootTest and camel-rest

2024-02-18 Thread Alphonse Bendt
i tried to

* add camel-platform-http-starter and camel-platform-http => this causes the 
same behavior
* replace camel-servlet-starter with platform-http-* => this causes a 404 as 
the endpoint apparently is not properly registered

> Am 18.02.2024 um 15:11 schrieb Claus Ibsen :
> 
> Hi
> 
> You can try using platform-http-starter instead of servlets
> 
> On Sun, Feb 18, 2024 at 3:09 PM Alphonse Bendt 
> wrote:
> 
>> Hi folks,
>> 
>> There is an issue when running tests for a SpringBoot application that
>> uses camel-rest.
>> 
>> When there are multiple tests that use a different configuration (e.g.,
>> different properties), we run into this error:
>> 
>> Caused by:
>>jakarta.servlet.ServletException: Duplicate
>> ServletName detected: CamelServlet. Existing:
>> CamelHttpTransportServlet[name=CamelServlet] This:
>> CamelHttpTransportServlet[name=CamelServlet]. Its advised to use unique
>> ServletName per Camel application.
>>at
>> app//org.apache.camel.component.servlet.CamelHttpTransportServlet.init(CamelHttpTransportServlet.java:68)
>> 
>> 
>> I have created a standalone example to demonstrate the issue:
>> https://github.com/abendt/camel-rest
>> 
>> To reproduce:
>> ./gradlew -i test
>> 
>> The project contains two tests with different configurations (one has an
>> additional active profile).
>> I would expect the build to pass; however, it fails with the mentioned
>> exception.
>> 
>> As a workaround, it's possible to add @DirtiesContext. However, this hurts
>> test performance and should be avoided if possible.
>> 
>> Am i missing something or is this a current limitation of camel-rest?
>> 
>> thanks,
>>   Alphonse
> 
> 
> 
> -- 
> Claus Ibsen
> -
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



Issue with SpringBootTest and camel-rest

2024-02-18 Thread Alphonse Bendt
Hi folks,

There is an issue when running tests for a SpringBoot application that uses 
camel-rest.

When there are multiple tests that use a different configuration (e.g., 
different properties), we run into this error:

 Caused by:
jakarta.servlet.ServletException: Duplicate ServletName 
detected: CamelServlet. Existing: CamelHttpTransportServlet[name=CamelServlet] 
This: CamelHttpTransportServlet[name=CamelServlet]. Its advised to use unique 
ServletName per Camel application.
at 
app//org.apache.camel.component.servlet.CamelHttpTransportServlet.init(CamelHttpTransportServlet.java:68)


I have created a standalone example to demonstrate the issue:
https://github.com/abendt/camel-rest

To reproduce:
./gradlew -i test

The project contains two tests with different configurations (one has an 
additional active profile).
I would expect the build to pass; however, it fails with the mentioned 
exception.

As a workaround, it's possible to add @DirtiesContext. However, this hurts test 
performance and should be avoided if possible.

Am i missing something or is this a current limitation of camel-rest?

thanks,
   Alphonse

AWS Kinesis Consumer

2023-12-16 Thread Alphonse Bendt
Hi folks,

A couple of days ago, I asked about resuming an AWS kinesis stream consumer:

https://lists.apache.org/thread/sc6oks5jckcbj19t06chmfpm6dpwt60t

I have experimented a bit more with the camel codebase and think now that there 
is functionality missing to allow implementing a ResumeStrategy for a Kinesis 
consumer:

I think the consumer should make the shardId available, plus I think the API of 
the KinesisResumeAdapter needs to be modified.
I have created a Branch with both proposed changes (see 
https://github.com/apache/camel/pull/12462/files). 
With these changes, I could sketch a custom ResumeStrategy (see branch).

Is this something you would accept as a PR?

Regards,
Alphonse





AWS Kinesis Consumer

2023-12-11 Thread Alphonse Bendt
Hi folks,

For a project, I was evaluating how to use the Camel AWS Kinesis component to 
consume from a Kinesis stream.

I am currently trying to understand how to properly set upstream offset 
handling so that an application can be restarted and won’t need to re-consume 
the whole stream.

The problem is that with a basic setup 
from(„aws2-kinesis://my-stream“).bean(myConsumer) the consumer will re-consume 
the whole stream on restart.

So, I have looked into implementing a resume strategy
https://camel.apache.org/components/4.0.x/eips/resume-strategies.html

It’s unclear to me how it is supposed to work, and I have some questions:
* Are there implementations of ResumeStrategy that work with Kinesis available, 
or are users supposed to implement their own? I could only find 
TransientResumeStrategy, which is in memory only. 

I tried to implement a custom strategy and ran into some questions:

My understanding is that I need to set the message header CamelOffset to ensure 
my strategy is updated with the offsets of the kinesis events that were 
processed:

from("aws2-kinesis://my-stream")
.resumable(„myResumeStrategy")
.process { ex ->
ex.message.setHeader(
Exchange.OFFSET,
Resumables.of(
ex.message.getHeader("CamelAwsKinesisShardId"),
ex.message.getHeader("CamelAwsKinesisSequenceNumber"),
),
)
}

I understand that the resumeStrategy would need to know which sequence number 
was processed last per Shardid. This mapping is then stored in a persistent 
ResumeCache.

However, this doesn't seem to work as CamelAwsKinesisShardId is not available 
in the consumer 
(https://github.com/apache/camel/blob/main/components/camel-aws/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/Kinesis2Consumer.java#L293)

Also, how is the interaction between KinesisResumeAdapter and Kinesis2Consumer 
supposed to work? 
(https://github.com/apache/camel/blob/main/components/camel-aws/camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/Kinesis2Consumer.java#L280-L283)

In my understanding, the adapter would require the current shardId as a 
parameter to update the GetShardIteratorRequest with the sequence-number from 
the ResumeCache.
However, the only parameter seems to be the stream name.

Thanks in advance for any help/insights!





Re: Camel HTTP/2 support

2023-10-09 Thread Alphonse Bendt
Thanks,

I had already tried out the http component. Now I also tried out netty, 
undertow and vert.x http. All of them don’t seem to support http/2.
Looks like the rest component just uses the mentioned components.

So i will go with the custom processor for now. 

Alphonse

> Am 08.10.2023 um 23:59 schrieb ski n :
> 
> Camel provides various HTTP clients like:
> 
> 1. http (https://camel.apache.org/components/4.0.x/http-component.html)
> 2. netty http (
> https://camel.apache.org/components/4.0.x/netty-http-component.html)
> 3. vert.x http (
> https://camel.apache.org/components/4.0.x/vertx-http-component.html)
> 4. rest (https://camel.apache.org/components/4.0.x/rest-component.html)
> 
> I don't know if any of those client explicitly support HTTP/2, but if not,
> you can make a custom processor:
> 
> https://camel.apache.org/manual/processor.html
> 
> And then run a http request (*java.net.http.HttpRequest*) like this:
> 
> HttpRequest request = HttpRequest.newBuilder()
>  .uri(new URI("https://postman-echo.com/get;))
>  .version(HttpClient.Version.HTTP_2)
>  .GET()
>  .build();
> 
> In the HTTP client since JDK 11 you can explicitly set the version.
> 
> Raymond
> 
> 
> 
> 
> On Sun, Oct 8, 2023 at 7:17 PM Alphonse Bendt 
> wrote:
> 
>> Hi folks,
>> 
>> How can I use Camel to send HTTP/2 requests to an existing HTTP/2 endpoint?
>> 
>> I tried out the http-component and it does not seem to support http/2.
>> Are there any other camel components available that support that? Are
>> there any plans to extend the http-component with http/2 support?
>> What other alternatives are there?
>> 
>> Thanks in advance,
>>   Alphonse
>> 
>> 



Camel HTTP/2 support

2023-10-08 Thread Alphonse Bendt
Hi folks,

How can I use Camel to send HTTP/2 requests to an existing HTTP/2 endpoint?

I tried out the http-component and it does not seem to support http/2.
Are there any other camel components available that support that? Are there any 
plans to extend the http-component with http/2 support?
What other alternatives are there?

Thanks in advance,
   Alphonse



Re: How do I setup camel-rest in combination with spring-webflux-netty?

2023-09-22 Thread Alphonse Bendt
Hi,

Thanks for that. Unfortunately this does not seem to work for me. My steps:

* added dependency to camel-platform-http-starter
* this has a transitive dependency on spring-boot-starter-web and tomcat, so I 
excluded them from the dependencies
* reconfigure camel-rest: getRestConfiguration().setComponent("platform-http“)

With this configuration I get classnotfoundexceptions while trying to run the 
springboottests.
java.lang.ClassNotFoundException: 
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping

I’ll stick with spring-boot-starter-web and tomcat for now.

Thanks so far!


> Am 21.09.2023 um 13:25 schrieb Claus Ibsen :
> 
> Hi
> 
> Use the platform-http for the consumer - then you use what spring comes
> with as http server.
> 
> 
> On Thu, Sep 21, 2023 at 1:04 PM Alphonse Bendt 
> wrote:
> 
>> Hi folks,
>> 
>> Within a Spring boot application I want to use camel-rest as consumer to
>> be able to define rest endpoints:
>> 
>> from(„rest://get/hello-world“).constant(„Some static content“)
>> 
>> This works fine with the spring-boot-starter-web which uses Tomcat:
>> 
>> Get http://localhost:8080/rest/hello-world => 200
>> 
>> Now I was trying to achieve the same with spring-boot-starter-webflux +
>> netty
>> 
>> What I did so far is:
>> * exchange spring-boot-starter-web with spring-boot-sterter-webflux
>> * add camel-netty-http
>> * configured the rest component to use netty-http instead of servlet:
>> getRestConfiguration().setComponent("netty-http“)
>> 
>> I can see in the log output that the route still is being registered
>> however cannot be accessed in the spring application
>> Get http://localhost:8080/rest/hello-world => 404
>> 
>> I am assuming that a new ServerPort is being opened instead of hooking
>> into the one already provided by spring?
>> 
>> How do i configure things so that the rest endpoint is accessible via the
>> Spring server port? Can anyone show me directions?
>> 
>> Thanks in advance,
>>   Alphonse
>> 
>> 
>> 
>> 
> 
> -- 
> Claus Ibsen
> -
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



How do I setup camel-rest in combination with spring-webflux-netty?

2023-09-21 Thread Alphonse Bendt
Hi folks,

Within a Spring boot application I want to use camel-rest as consumer to be 
able to define rest endpoints:

from(„rest://get/hello-world“).constant(„Some static content“)

This works fine with the spring-boot-starter-web which uses Tomcat:

Get http://localhost:8080/rest/hello-world => 200

Now I was trying to achieve the same with spring-boot-starter-webflux + netty

What I did so far is:
* exchange spring-boot-starter-web with spring-boot-sterter-webflux
* add camel-netty-http
* configured the rest component to use netty-http instead of servlet: 
getRestConfiguration().setComponent("netty-http“)

I can see in the log output that the route still is being registered however 
cannot be accessed in the spring application
Get http://localhost:8080/rest/hello-world => 404

I am assuming that a new ServerPort is being opened instead of hooking into the 
one already provided by spring?

How do i configure things so that the rest endpoint is accessible via the 
Spring server port? Can anyone show me directions?

Thanks in advance,
   Alphonse