gnodet-bot commented on code in PR #30504:
URL: https://github.com/apache/camel/pull/30504#discussion_r4664804417
##########
components/camel-knative/camel-knative-component/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java:
##########
@@ -56,6 +56,14 @@ public class KnativeConfiguration implements Cloneable {
private Boolean reply;
@UriParam(label = "consumer", defaultValue = "true")
private boolean muteException = true;
+ @UriParam(label = "consumer",
Review Comment:
The new `@UriParam` annotation on `synchronous` omits `defaultValue`. The
adjacent `muteException` field (line 58) uses `@UriParam(..., defaultValue =
"true")`, establishing the convention for boolean fields in this class. Without
`defaultValue`, the docs page shows no default.
```suggestion
@UriParam(label = "consumer", defaultValue = "false",
```
##########
components/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpConsumer.java:
##########
@@ -236,55 +239,83 @@ private void handleRequest(RoutingContext routingContext)
{
// from("knative:event/my.event")
//
.to("http://{{env:PROJECT}}.{{env:NAMESPACE}}.svc.cluster.local/service");
//
- routingContext.vertx().executeBlocking(() -> {
- createUoW(exchange);
- getAsyncProcessor().process(exchange);
- return null;
- },
- false)
- .onComplete(result -> {
- try {
- Throwable failure = null;
-
- if (result.succeeded()) {
- try {
- HttpServerResponse response =
toHttpResponse(request, exchange.getMessage());
- Buffer body = null;
-
- if (request.response().getStatusCode() != 204
&& configuration.isReply()) {
- body =
computeResponseBody(exchange.getMessage());
-
- String contentType =
MessageHelper.getContentType(exchange.getMessage());
- if (contentType != null) {
-
response.putHeader(Exchange.CONTENT_TYPE, contentType);
- }
- }
-
- if (body != null) {
- request.response().end(body);
- } else {
- // 204 tells the caller that the event has
been delivered: a failed exchange
- // without reply keeps its error status,
so that the event is sent again
- if (!exchange.isFailed()) {
- request.response().setStatusCode(204);
- }
- request.response().end();
- }
- } catch (Exception e) {
- failure = e;
- }
- } else if (result.failed()) {
- failure = result.cause();
+ // The route runs with the asynchronous processor: the worker thread
is free once the route
+ // continues on another thread, so a route that calls an asynchronous
producer on the same
+ // Vert.x (such as vertx-http in Camel Quarkus) does not exhaust the
worker pool.
+ // With the endpoint option synchronous=true, the worker thread runs
the route with the
+ // synchronous processor, so it is held until the route completes, and
the worker pool
+ // bounds the requests in flight.
+ Context context = routingContext.vertx().getOrCreateContext();
Review Comment:
`context` is captured before the `if/else` branch but is only used in the
`else` (async) path — the synchronous path at line 251 never references it.
The two sibling consumers (`VertxWebsocketConsumer`,
`VertxWebsocketClientConsumer`) correctly scope the variable inside the `else`
block. Move it there to match:
```suggestion
if (((KnativeEndpoint) getEndpoint()).isSynchronous()) {
```
Move the `Context context = ...` line inside the `else {` block.
##########
components/camel-vertx/camel-vertx-websocket/src/main/java/org/apache/camel/component/vertx/websocket/VertxWebsocketEndpoint.java:
##########
@@ -82,6 +82,14 @@ public class VertxWebsocketEndpoint extends DefaultEndpoint
implements EndpointS
@UriParam
private VertxWebsocketConfiguration configuration;
+ @UriParam(label = "consumer",
Review Comment:
Same issue as `KnativeConfiguration.java`: `@UriParam` on `synchronous`
omits `defaultValue = "false"`.
```suggestion
@UriParam(label = "consumer", defaultValue = "false",
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]