Re: Jetty Component how to add additional steps after send http response back to the client
Dear Claus lbsen, Thanks so much for your suggestions, I will try both. Thanks again for your kind help. Have a nice day. :) From: Claus Ibsen Sent: Sunday, November 19, 2023 3:36:23 AM To: users@camel.apache.org Subject: Re: Jetty Component how to add additional steps after send http response back to the client 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
Or take a look at the wire tap pattern: https://camel.apache.org/components/4.0.x/eips/wireTap-eip.html Raymond On Sun, Nov 19, 2023 at 2:05 PM Claus Ibsen wrote: > Hi > > You can also look at using onCompletion > https://camel.apache.org/manual/oncompletion.html > > On Sat, Nov 18, 2023 at 8:36 PM Claus Ibsen wrote: > > > 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 > > > > > -- > 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
Hi You can also look at using onCompletion https://camel.apache.org/manual/oncompletion.html On Sat, Nov 18, 2023 at 8:36 PM Claus Ibsen wrote: > 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 > -- 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
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
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
回复: Jetty Component how to add additional steps after send http response back to the client
Dear all, Does anyone have idea regarding this question? Or any workaroud? I appreciate all the inputs. Thanks in advance~ 发件人: Han Yainsun 发送时间: 2023年11月14日 4:09 收件人: users@camel.apache.org 主题: Jetty Component how to add additional steps after send http response back to the client 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()));
Jetty Component how to add additional steps after send http response back to the client
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()));