[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17233469#comment-17233469 ] Romain Manni-Bucau commented on CAMEL-11731: [~davsclaus] sure: https://github.com/apache/camel/pull/4617 > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17233096#comment-17233096 ] Claus Ibsen commented on CAMEL-11731: - Romain you are welcome to work on PR. Would be good for one PR with the null/empty fix. And another for the async. > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17231376#comment-17231376 ] Romain Manni-Bucau commented on CAMEL-11731: Any way it moves forward? Currently i'm using something like [https://gist.github.com/rmannibucau/3dc9f98ca444732e894fdb4e8251a9e2] Only changes are to use the async processor instead of sync processor for the consumer (can be an instanceof check to keep it generic) and moving the asyncContext.complete() after the processing. Side note: fully unrelated but saw it while working on that: OPTIONS allowedMethods logic tests null instead of isEmpty()/isBlank(), guess it is a bug introduce by moving to streams. > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16409078#comment-16409078 ] ASF GitHub Bot commented on CAMEL-11731: onderson commented on issue #2188: CAMEL-11731 - add asynccallback and sync camel and servlet async APIs URL: https://github.com/apache/camel/pull/2188#issuecomment-375187032 @nhoughto , processing asychronously in camel and servlet brings up the ordering problem which @davsclaus described earlier. I thought it would not be that to easy to sort this out by myself. So i did pull out the PR. Hope somebody else will take a look at this. I have a similar scenario but not killing me at the moment. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16383150#comment-16383150 ] ASF GitHub Bot commented on CAMEL-11731: nhoughto commented on issue #2188: CAMEL-11731 - add asynccallback and sync camel and servlet async APIs URL: https://github.com/apache/camel/pull/2188#issuecomment-369815760 is a shame this has been closed, I was waiting for it. What was left to complete? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16371856#comment-16371856 ] ASF GitHub Bot commented on CAMEL-11731: onderson commented on issue #2188: CAMEL-11731 - add asynccallback and sync camel and servlet async APIs URL: https://github.com/apache/camel/pull/2188#issuecomment-367432193 PR withdrawn. Thanks This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Assignee: Önder Sezgin >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16371858#comment-16371858 ] ASF GitHub Bot commented on CAMEL-11731: Github user onderson closed the pull request at: https://github.com/apache/camel/pull/2188 > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Assignee: Önder Sezgin >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16371857#comment-16371857 ] ASF GitHub Bot commented on CAMEL-11731: onderson closed pull request #2188: CAMEL-11731 - add asynccallback and sync camel and servlet async APIs URL: https://github.com/apache/camel/pull/2188 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/camel-core/src/main/docs/eips/serviceCall-eip.adoc b/camel-core/src/main/docs/eips/serviceCall-eip.adoc index c3ade43224b..b90460468b0 100644 --- a/camel-core/src/main/docs/eips/serviceCall-eip.adoc +++ b/camel-core/src/main/docs/eips/serviceCall-eip.adoc @@ -100,18 +100,18 @@ The Service Call EIP supports 14 options which are listed below: | Name | Description | Default | Type | *name* | *Required* Sets the name of the service to use | | String | *uri* | The uri of the endpoint to send to. The uri can be dynamic computed using the org.apache.camel.language.simple.SimpleLanguage expression. | | String -| *component* | The component to use | http4 | String +| *component* | The component to use. | http4 | String | *pattern* | Sets the optional ExchangePattern used to invoke this endpoint | | ExchangePattern | *configurationRef* | Refers to a ServiceCall configuration to use | | String -| *serviceDiscoveryRef* | Sets a reference to a custom ServiceDiscovery to use | | String -| *serviceFilterRef* | Sets a reference to a custom ServiceFilter to use | | String -| *serviceChooserRef* | Sets a reference to a custom ServiceChooser to use | | String -| *loadBalancerRef* | Sets a reference to a custom ServiceLoadBalancer to use | | String -| *expressionRef* | Set a reference to a custom Expression to use | | String -| *serviceDiscovery Configuration* | *Required* Configures the ServiceDiscovery using the given configuration | | ServiceCallService DiscoveryConfiguration -| *serviceFilterConfiguration* | *Required* Configures the ServiceFilter using the given configuration | | ServiceCallService FilterConfiguration -| *loadBalancerConfiguration* | *Required* Configures the LoadBalancer using the given configuration | | ServiceCallServiceLoad BalancerConfiguration -| *expressionConfiguration* | *Required* Configures the Expression using the given configuration | | ServiceCallExpression Configuration +| *serviceDiscoveryRef* | Sets a reference to a custom ServiceDiscovery to use. | | String +| *serviceFilterRef* | Sets a reference to a custom ServiceFilter to use. | | String +| *serviceChooserRef* | Sets a reference to a custom ServiceChooser to use. | | String +| *loadBalancerRef* | Sets a reference to a custom ServiceLoadBalancer to use. | | String +| *expressionRef* | Set a reference to a custom Expression to use. | | String +| *serviceDiscovery Configuration* | *Required* Configures the ServiceDiscovery using the given configuration. | | ServiceCallService DiscoveryConfiguration +| *serviceFilterConfiguration* | *Required* Configures the ServiceFilter using the given configuration. | | ServiceCallService FilterConfiguration +| *loadBalancerConfiguration* | *Required* Configures the LoadBalancer using the given configuration. | | ServiceCallServiceLoad BalancerConfiguration +| *expressionConfiguration* | *Required* Configures the Expression using the given configuration. | | ServiceCallExpression Configuration |=== // eip options: END diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java b/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java index 19755b490b8..abf5309d55e 100644 --- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java +++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java @@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.camel.AsyncCallback; import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.RuntimeCamelException; @@ -75,7 +76,19 @@ protected final void service(HttpServletRequest req, HttpServletResponse resp) t //run async context.start(() -> doServiceAsync(context)); } else { -doService(req, resp); +try { +doService(req, resp); +} catch (Exception e) { +//An error shouldn't occur as we should handle most of error in doService +log.error("Error processing request", e); +try { +
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16350168#comment-16350168 ] ASF GitHub Bot commented on CAMEL-11731: davsclaus commented on issue #2188: CAMEL-11731 - add asynccallback and sync camel and servlet async APIs URL: https://github.com/apache/camel/pull/2188#issuecomment-362555789 Its more tricky than that, the Camel routing engine can process sync and async depending on what happens in the Camel routes / components in use etc. And that complete method must be called regardless at the right time, and only when all the data is done being written in the reply. So ordering matter, and also it maybe must be called even if Camel routing engine was not kicked as something failed beforehand. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Assignee: Önder Sezgin >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16350203#comment-16350203 ] ASF GitHub Bot commented on CAMEL-11731: onderson commented on issue #2188: CAMEL-11731 - add asynccallback and sync camel and servlet async APIs URL: https://github.com/apache/camel/pull/2188#issuecomment-362565907 in doServiceAsync method, all the exceptions must be handled and in finally block `asyncCallback.done(false)` must be called so that ,after proper error message provided in HttpServletResponse ,context should be completed as a result of it. I think i understand what you mean by the importance of ordering, maybe in callback handler's implementation, instead of > public void done(boolean doneSync) { >if (!doneSync) { >context.complete(); >} >} it should be > public void done(boolean doneSync) { > context.complete(); > } and in here, context should not be completed before camel's async processing is completed. So, i am wondering in such case would it be simpler not having camel's async processing may not be needed if Camel Servlet is already asynchronous. So would it make the current behaviour close to correct handling? or it will be more complicated to syncronize both async behaviours somewhere else. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Assignee: Önder Sezgin >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16350201#comment-16350201 ] ASF GitHub Bot commented on CAMEL-11731: onderson commented on issue #2188: CAMEL-11731 - add asynccallback and sync camel and servlet async APIs URL: https://github.com/apache/camel/pull/2188#issuecomment-362565907 in doServiceAsync method, all the exceptions must be handled and in finally block `asyncCallback.done(false)` must be called so that ,after proper error message provided in HttpServletResponse ,context should be completed as a result of it. I think i understand what you mean by the importance of ordering, maybe in callback handler's implementation, instead of `public void done(boolean doneSync) { if (!doneSync) { context.complete(); } }` it should be `public void done(boolean doneSync) { context.complete(); }` and in here, context should not be completed before camel's async processing is completed. So, i am wondering in such case would it be simpler not having camel's async processing may not be needed if Camel Servlet is already asynchronous. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Assignee: Önder Sezgin >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16348320#comment-16348320 ] ASF GitHub Bot commented on CAMEL-11731: onderson commented on issue #2188: CAMEL-11731 - add asynccallback and sync camel and servlet async APIs URL: https://github.com/apache/camel/pull/2188#issuecomment-362216834 AFAIK, async servlet API handles requests by writing to HttpServletResponse and setting context.complete(). Currently (before what i have done) what is done in CamelServlet is to do this and process camel's exchange with `consumer.getProcessor().process`. What i have added is to call `consumer.getAsyncProcessor().process(exchange, asyncCallback)` with a proper asyncCallBack in which callkback.done(false) is called after completing to write to HttpServletResponse, which will trigger context.complete(). If you can describe what your thinking around the subject of the complexity, i'd like to try to implement.. Thanks for the review. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Assignee: Önder Sezgin >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16348295#comment-16348295 ] ASF GitHub Bot commented on CAMEL-11731: davsclaus commented on issue #2188: CAMEL-11731 - add asynccallback and sync camel and servlet async APIs URL: https://github.com/apache/camel/pull/2188#issuecomment-362211942 This is not entirely correct, its more complicated to implement This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Assignee: Önder Sezgin >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16333528#comment-16333528 ] ASF GitHub Bot commented on CAMEL-11731: GitHub user onders86 opened a pull request: https://github.com/apache/camel/pull/2188 CAMEL-11731 - add asynccallback and sync camel and servlet async APIs You can merge this pull request into a Git repository by running: $ git pull https://github.com/onders86/camel CAMEL-11731 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/camel/pull/2188.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2188 commit 069cba14eae2c6621c1a93c2bc0b03e38065e1ce Author: onders86Date: 2018-01-19T13:27:15Z CAMEL-11731 - add asynccallback and sync camel and servlet async APIs > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Improvement > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton >Assignee: Önder Sezgin >Priority: Major > Fix For: Future > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CAMEL-11731) Servlet Component isn't really async
[ https://issues.apache.org/jira/browse/CAMEL-11731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16151735#comment-16151735 ] Claus Ibsen commented on CAMEL-11731: - Yeah you are welcome to do a PR, it requires a bit of logic to implement correct, as all the work after the process, should be done in the AsyncCallback etc so its a bit more complex to do. Also the async servlet api is fairly new and therefore not so much in use. > Servlet Component isn't really async > > > Key: CAMEL-11731 > URL: https://issues.apache.org/jira/browse/CAMEL-11731 > Project: Camel > Issue Type: Bug > Components: camel-servlet >Affects Versions: 2.18.4, 2.19.2 > Environment: All >Reporter: Nick Houghton > Fix For: 2.20.0 > > > So my assumption reading the servlet component doco is that with 2.18+ and a > Servlet 3+ container, the component supports async, which it kind of does > with the async=true init config, and there is even a method in CamelServlet > called "doServiceAsync" but from what i can tell it doesn't really do it in a > asynchronous manner, where there are no blocked threads while a request is > awaiting an async operation (like an AHC call for example). > Looking at: > https://github.com/apache/camel/blob/master/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java > While processing a request, we check if we are in async mode and call > doServiceAsync.. > {code:java} > @Override > protected final void service(HttpServletRequest req, HttpServletResponse > resp) throws ServletException, IOException { > if (isAsync()) { > final AsyncContext context = req.startAsync(); > //run async > context.start(() -> doServiceAsync(context)); > } else { > doService(req, resp); > } > } > {code} > then in doServiceAsync() we call doService().. and then we call > getProcessor().process(exchange), not process(exchange, asyncCallback) which > is the proper async method.. > {code:java} > try { > if (log.isTraceEnabled()) { > log.trace("Processing request for exchangeId: {}", > exchange.getExchangeId()); > } > // process the exchange > consumer.getProcessor().process(exchange); > } catch (Exception e) { > exchange.setException(e); > } > {code} > So the actual behaviour is an inbound request in async mode that ends up just > blocking waiting for the request to complete, in a totally sync manner. I > presume this is not the desired behaviour? > It seems the fix would be to move the doService() logic to doServiceAsync() > and have doService() call it and use the AsyncProcessorConverterHelper. Or > the other alternative would be to update the documentation to explicitly note > that it is actually not async at all. > I can probably PR it in, just wanted to get thoughts on the actual intention. -- This message was sent by Atlassian JIRA (v6.4.14#64029)