Integration / Apache Camel Interview Questions
What is the Message in Camel (body, headers, attachments) and the difference between In and Out messages?
A Camel Message (org.apache.camel.Message) is the envelope carried inside an Exchange. It has three parts: body (any Java object — String, byte[], InputStream, POJO, DOM — type-converted transparently via getBody(TargetClass.class)), headers (a Map<String, Object> of metadata auto-populated by transport components), and attachments (named DataHandler objects for SOAP/MIME multipart messages).
In vs Out messages: In an InOnly exchange, only the In message exists; JMS publish, Kafka produce, and file write are InOnly by default. In an InOut exchange, the caller sends an In message and waits for a reply via the Out message; HTTP REST calls and synchronous direct: calls use InOut.
In Camel 3.x, the idiomatic reply approach is to mutate exchange.getIn() with the response body rather than writing to exchange.getOut(). Calling getOut() creates a fresh Message and silently discards all headers set by prior processors — a common source of bugs during Camel 3.x migrations.
More Related questions...