Hi, Any help on this?
On Tue, Jan 21, 2020 at 5:56 PM Narsi Reddy Nallamilli < narsi.nallami...@gmail.com> wrote: > Hi, > > I moved from 2.x to 3.x and see getOut() on exchange is now depreciated. > But the intention to replace it with getMessage is not inline with the > behaviour of getOut(). > > > https://camel.apache.org/manual/latest/camel-3-migration-guide.html#_getout_on_message > > As stated in above link the getMessage is simple replace to getOut but its > implementation is different, > > This is the implementation where we see it returns In message if out > message does not exist. But this is not inline with expectation. When > response is null in case when there is some error like server error then > this implementation is return IN message. > > > https://github.com/apache/camel/blob/master/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchange.java > > @Override > public Message getMessage() { > return hasOut() ? getOut() : getIn(); > } > > Test > Exchange endpointExchange = new DefaultExchange(getCamelContext()); > Map<String, Object> headers = new HashMap<>(); > headers.put(Exchange.HTTP_METHOD, HttpMethod.GET); > endpointExchange.getIn().setHeaders(headers); > endpointExchange.getIn().setBody("test"); > List<Future<Exchange>> futureExchangeList = new > ArrayList<Future<Exchange>>(); > Future<Exchange> futureExchange = jobProducerTemplate.asyncSend(" > https://httpstat.us/500", endpointExchange); > futureExchangeList.add(futureExchange); > for (Future<Exchange> futureExchange : futureExchangeList) { > Exchange ex = null; > try { > ex = futureExchange.get(); > } catch (InterruptedException | ExecutionException e) { > } > System.out.println(ex.getIn().getBody(String.class)); > System.out.println(ex.getMessage().getBody()); > System.out.println(ex.getOut().getBody()); > } > > Here 2. sysout prints the In message which is incorrect. > 3. systout prints null since the actual response is null > >