hingiswiss
hingiswiss

Reputation: 47

in-Message copied in out-Message

I have this simple route in my RouteBuilder.

from("amq:MyQueue").routeId(routeId).log(LoggingLevel.DEBUG, "Log: ${in.headers} - ${in.body}")

As stated in the doc for HTTP-component:

Camel will store the HTTP response from the external server on the OUT body. All headers from the IN message will be copied to the OUT message, ...

I would like to know if this concept also applies to amq-component, routeId, and log? Is it the default behaviour, that IN always gets copied to OUT?

Thank you, Hadi

Upvotes: 1

Views: 322

Answers (1)

burki
burki

Reputation: 7035

First of all: The concept of IN and OUT messages is deprecated in Camel 3.x.

This is mentioned in the Camel 3 migration guide and also annotated on the getOut method of the Camel Exchange.

However, it is not (yet) removed, but what you can take from it: don't care about the OUT message. Use the getMessage method and don't use getIn and getOut anymore.

To answer your question:

Yes, most components behave like this

  • Every step in the route takes the (IN) message and processes it
  • The body is typically overwritten with the new processing result
  • The headers typically stay, new headers can be added

So while the Camel Exchange traverses the route, typically the body is continuously updated and the header list grows.

However, some components like aggregator create new messages based on an AggregationStrategy. In such cases nothing is copied automatically and you have to implement the strategy to your needs.

Upvotes: 2

Related Questions