Hi

You did it wrong in 3.10. If you want to do a fork/join via multicast
then it has built-in aggregation strategy you should use. Do not use
aggregate eip at all.
What happens is the output of the aggregate is completely separated
from the input (even for size = 1). In 3.11 that is even more so, and
that is why the http servlet stream is closed / done
as that work is done by the consumer thread.




On Mon, Sep 6, 2021 at 11:09 AM Adamec, Michael
<[email protected]> wrote:
>
> Hello everyone,
>
> We are experiencing issue in our project after upgrading Apache Camel from 
> version 3.10.0 to 3.11.0. The same route which worked without any problems in 
> previous versions, does not work now. We managed to simplify the route from 
> our project and simulate the problem on this simplified route.
>
> Route looks like this:
>
> // HTTP Input
> from("servlet:///httpIssue?httpMethodRestrict=GET&servletName=CamelServlet")
>         .log("Http request received")
>         .process(new CorrelationIdGenerator())
>         .to(parallelSplitterEndpoint);
>
> // Parallel Splitter
> from(parallelSplitterEndpoint)
>         .log("Parallel Splitter")
>         .multicast()
>         .executorService(executorService)
>         .parallelProcessing()
>         .to(new String[]{synchronizerEndpoint});
>
> // Parallel Synchronizer
> from(synchronizerEndpoint)
>         .log("Parallel Synchronizer")
>         .setHeader("scaler-sync-correlation", correlationExpression)
>         .aggregate(correlationExpression, new MyRoutesAggregator())
>         .completionSize(1)
>         .to(httpOutputEndpoint);
>
> // HTTP Output
> from(httpOutputEndpoint)
>         .log("HTTP Output")
>         .process(new ProcessHttpOutput());
>
>
> In ProcessHttpOutput processor we are writing the response into the 
> OutputStream:
>
>
> private static class ProcessHttpOutput implements Processor {
>     @Override
>     public void process(Exchange exchange) throws Exception {
>         HttpServletResponse response = 
> exchange.getMessage().getBody(HttpMessage.class).getResponse();
>         response.setStatus(200);
>         try (ServletOutputStream outputStream = response.getOutputStream()) {
>             outputStream.write(("Response").getBytes(StandardCharsets.UTF_8));
>             outputStream.flush();
>         }
>     }
> }
>
> If we run this route on Camel version 3.11.0. We are getting 
> NullPointerException during flushing / closing the stream. It works without 
> any problems on 3.10.0.
>
> The problem is only when using multicast and subsequent aggregation in the 
> route (without aggregation it works fine). After aggregation, it is not 
> possible to write to the output stream.
>
>
> Here is the repository with the simplified route (branch 
> camel-minimal-sample):
> https://github.com/bugs84/springboot-camel-httpoutput-issue/tree/camel-minimal-sample
>
> Steps to reproduce:
> 1.      Run Application.java
> 2.      Route configuration is located in HttpOutputIssue.java
> 3.      Make GET request to http://localhost:8080/camel/httpIssue
>
>
> Can you please confirm that this is a bug? Or is it misconfiguration? We will 
> be grateful for any help with this issue.
>
> Thank you
> Michael
>


-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to