Re: Jetty Component how to add additional steps after send http response back to the client

2023-11-18 Thread Claus Ibsen
Hi

I would also add that HTTP servers like Tomcat, Jetty, JBoss etc have an
access log that logs how long time each request takes. And they often have
a API / plugin you can use to have your custom code triggered by the HTTP
server
so you can do any kind of "how long time it takes" you need.


On Sat, Nov 18, 2023 at 8:34 PM Claus Ibsen  wrote:

> Hi
>
> Camel will send back the response at the end of the route in the consumer,
> so what you do in that route example will not work.
> However if you want to do some kind of custom logging of how long it
> takes, then Camel Jetty has send back the response to the client, when the
> UnitOfWork is done.
> So you can use Camel's UoW done to do any custom code for "backend
> response timestamp ...".
>
> See the docs for UnitOfWork or its also covered in the CiA2 book.
>
>
>
> On Tue, Nov 14, 2023 at 5:11 AM Han Yainsun  wrote:
>
>> Dear Camel Community and Camel users,
>>
>> Greetings to you!
>>
>> Camel version: 3.20.4
>> Spring Boot version: 2.7.11
>> JDK: Amazon Corretto 17
>> Platform: Windows server 2019
>> IDE: IntelliJ IDEA 2021.3.2 (Community Edition)
>>
>> I have an requirement that need calculate each message process time,
>> incould total process time and backend process time. the route likes below,
>> it seems that the jetty managed the http session and send the response
>> back to client automatically at the end of route.
>>
>> Is it possible to explicitly inform jetty send the resonse at specific
>> point?
>>
>> Thansk in advance.
>>
>> from("jetty:http://0.0.0.0:8080/test;)
>> .process(exchange -> exchange.setProperty("inbound timestamp",
>> System.currentTimeMillis()))
>> .to("http://localhost/mockbackend;)
>> .process(exchange -> exchange.setProperty("backend respond timestamp",
>> System.currentTimeMillis()))
>> .setBody(constant("hello"))
>> // I expect jetty send response back to client here.
>> .process(exchange -> exchange.setProperty("backend respond timestamp",
>> System.currentTimeMillis()));
>>
>>
>
> --
> Claus Ibsen
> -
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


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


Re: Jetty Component how to add additional steps after send http response back to the client

2023-11-18 Thread Claus Ibsen
Hi

Camel will send back the response at the end of the route in the consumer,
so what you do in that route example will not work.
However if you want to do some kind of custom logging of how long it takes,
then Camel Jetty has send back the response to the client, when the
UnitOfWork is done.
So you can use Camel's UoW done to do any custom code for "backend response
timestamp ...".

See the docs for UnitOfWork or its also covered in the CiA2 book.



On Tue, Nov 14, 2023 at 5:11 AM Han Yainsun  wrote:

> Dear Camel Community and Camel users,
>
> Greetings to you!
>
> Camel version: 3.20.4
> Spring Boot version: 2.7.11
> JDK: Amazon Corretto 17
> Platform: Windows server 2019
> IDE: IntelliJ IDEA 2021.3.2 (Community Edition)
>
> I have an requirement that need calculate each message process time,
> incould total process time and backend process time. the route likes below,
> it seems that the jetty managed the http session and send the response
> back to client automatically at the end of route.
>
> Is it possible to explicitly inform jetty send the resonse at specific
> point?
>
> Thansk in advance.
>
> from("jetty:http://0.0.0.0:8080/test;)
> .process(exchange -> exchange.setProperty("inbound timestamp",
> System.currentTimeMillis()))
> .to("http://localhost/mockbackend;)
> .process(exchange -> exchange.setProperty("backend respond timestamp",
> System.currentTimeMillis()))
> .setBody(constant("hello"))
> // I expect jetty send response back to client here.
> .process(exchange -> exchange.setProperty("backend respond timestamp",
> System.currentTimeMillis()));
>
>

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


Re: Learning camel quarkus using kotlin

2023-11-18 Thread Matthew Karas
I was able to get the repo to run the tests correctly past this
particular issue.  All the changes I made to get it to work are in
this commit

https://github.com/lucidguppy/learning-quarkus-camel-testing/commit/3200e96ad46e9579ba4c085e2a8bba4c090f3d8e

What tipped me off was debugging and seeing everything get initiated
in the correct way, but the injection test kept saying the field in
question didn't have the injection notation I created.

The link that tipped me off on how to annotate the annotation in
kotlin so it would work is here:
https://discuss.kotlinlang.org/t/confusion-about-field-annotation/26272/5

Phew - that was a challenge.

On Sat, Nov 18, 2023 at 11:03 AM Matthew Karas
 wrote:
>
> Hello,
>
> I am learning how to properly test camel code using test containers
> and I am finding difficulty with lateinit items in my test when trying
> to inject items created in QuarkusTestResourceLifecycleManager that
> are injected into the test.  Ultimately - I would like to be able to
> set up resources in localstack before the test runs and tear them down
> afterwards.
>
> My code you can find here:
> https://github.com/lucidguppy/learning-quarkus-camel-testing/blob/main/src/test/kotlin/com/example/PlanetaryConduitRouteTest.kt
>
> My intent is to use the technique as described in "Injection into tests"
> https://quarkus.io/guides/getting-started-testing#injection-into-tests
>
> I then added a commit to attempt the technique as described here
> https://quarkus.io/guides/getting-started-testing#altering-the-test-class
>
> I'm getting the following error message.
>
> kotlin.UninitializedPropertyAccessException: lateinit property s3 has
> not been initialized
> at 
> com.example.PlanetaryConduitRouteTest.getS3(PlanetaryConduitRouteTest.kt:82)
>
> At this point I'm not even testing the routes - all I'm trying to do
> is set up and tear down s3 buckets in the setUp and tearDown.
>
> Any help would be greatly appreciated.


Learning camel quarkus using kotlin

2023-11-18 Thread Matthew Karas
Hello,

I am learning how to properly test camel code using test containers
and I am finding difficulty with lateinit items in my test when trying
to inject items created in QuarkusTestResourceLifecycleManager that
are injected into the test.  Ultimately - I would like to be able to
set up resources in localstack before the test runs and tear them down
afterwards.

My code you can find here:
https://github.com/lucidguppy/learning-quarkus-camel-testing/blob/main/src/test/kotlin/com/example/PlanetaryConduitRouteTest.kt

My intent is to use the technique as described in "Injection into tests"
https://quarkus.io/guides/getting-started-testing#injection-into-tests

I then added a commit to attempt the technique as described here
https://quarkus.io/guides/getting-started-testing#altering-the-test-class

I'm getting the following error message.

kotlin.UninitializedPropertyAccessException: lateinit property s3 has
not been initialized
at 
com.example.PlanetaryConduitRouteTest.getS3(PlanetaryConduitRouteTest.kt:82)

At this point I'm not even testing the routes - all I'm trying to do
is set up and tear down s3 buckets in the setUp and tearDown.

Any help would be greatly appreciated.