onCompletion.onCompleteOnly().log() is invoked even when Camel fails the routing
Issue
Camel route
@Override
public void configure() {
rest("api")
.get("/download")
.consumes("application/json")
.produces("application/octet-stream")
.to("direct:send")
;
from("direct:send")
.onCompletion().onCompleteOnly()
.log("onCompletion()")
.end()
.process(exchange -> {
Path filePath = Paths.get("rhaf-camel-spring-boot-4.4.0.CS8-src.zip");
exchange.getIn().setBody(filePath.toFile());
})
.setHeader("CamelHttpResponseCode", constant(200))
.setHeader("Content-Disposition", simple("attachment; filename=rhaf-camel-spring-boot-4.4.0.CS8-src.zip"))
}
Failure test.(Timeout)
$ curl -O -J -X GET -H "Content-Type: application/json" "localhost:8080/api/download" --max-time 0.01
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (28) Operation timed out after 10 milliseconds with 0 bytes received
Although the client fails to receive a response, .log("onCompletion()") is executed.
2024-10-02T15:07:44.330+09:00 INFO 65048 --- [ XNIO-1 task-2] route1 : onCompletion()
Environment
- Red Hat Build of Apache Camel for Spring Boot
- 4.4.2
- Red Hat Build of Apache Camel for Quarkus
- 3.8
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.