davsclaus commented on code in PR #27390:
URL: https://github.com/apache/camel/pull/27390#discussion_r4191865657


##########
components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfConsumer.java:
##########
@@ -168,14 +168,30 @@ public Object invoke(Exchange cxfExchange, Object o) {
             Continuation continuation;
             if (!endpoint.isSynchronous() && 
isAsyncInvocationSupported(cxfExchange)
                     && (continuation = getContinuation(cxfExchange)) != null) {
+                // a resumed continuation belongs to a request that is in 
flight and must complete
+                if (continuation.isNew()) {
+                    rejectIfSuspended();
+                }
                 LOG.trace("Calling the Camel async processors.");
                 return asyncInvoke(cxfExchange, continuation);
             } else {
+                rejectIfSuspended();
                 LOG.trace("Calling the Camel sync processors.");
                 return syncInvoke(cxfExchange);
             }
         }
 
+        // a suspended consumer (suspended route, graceful shutdown) does not 
accept new requests, like the HTTP
+        // consumers, which answer 503
+        private void rejectIfSuspended() {

Review Comment:
   Question: CXF logs a `Fault` built from an `IllegalStateException` at WARN 
with a stack trace, so a graceful shutdown under load produces one stack trace 
per rejected request. You mention this in the PR; is a quieter path feasible? 
Not blocking.



##########
components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/component/cxf/jaxws/CxfConsumerSuspendTest.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.jaxws;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cxf.common.CXFTestSupport;
+import org.apache.camel.support.service.ServiceSupport;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.frontend.ClientFactoryBean;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.apache.cxf.transport.http.HTTPException;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * A suspended CXF consumer (suspended route, graceful shutdown, route 
policies) must not process new requests, while
+ * the requests in flight complete.
+ */
+class CxfConsumerSuspendTest extends CamelTestSupport {
+
+    private static final String ADDRESS = "http://localhost:"; + 
CXFTestSupport.getPort1() + "/CxfConsumerSuspendTest/test";
+
+    private final AtomicInteger processed = new AtomicInteger();
+    private final CountDownLatch entered = new CountDownLatch(1);
+    private final CountDownLatch release = new CountDownLatch(1);
+    private volatile boolean block;
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("cxf://" + ADDRESS + 
"?serviceClass=org.apache.camel.component.cxf.jaxws.HelloService")
+                        .routeId("cxf")
+                        .process(exchange -> {
+                            if (processed.incrementAndGet() == 1 && block) {
+                                entered.countDown();
+                                release.await(20, TimeUnit.SECONDS);
+                            }
+                            String text = (String) 
exchange.getIn().getBody(List.class).get(0);
+                            exchange.getMessage().setBody("echo " + text);
+                        });
+            }
+        };
+    }
+
+    @Test
+    void testSuspendedRouteRejectsRequests() throws Exception {
+        HelloService client = createClient();

Review Comment:
   Nit: each `createClient()` creates a new `Bus` that is never shut down, so 
the test leaks it. Shut it down after the test or reuse one bus.



-- 
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]

Reply via email to