What I have found is, that the exchange object which is passed to the DataFormat is only used for getting the CamelContext. I searched a little bit further and found a processor for unmarshalling:
org.apache.camel.processor.UnmarshalProcessor.process(Exchange, AsyncCallback) And there is a note Object result = dataFormat.unmarshal(exchange, stream); if (result instanceof Exchange) { if (result != exchange) { // it's not allowed to return another exchange other than the one provided to dataFormat throw new RuntimeCamelException("The returned exchange " + result + " is not the same as " + exchange + " provided to the DataFormat"); The logic of that processor is: - get the object from the stream - if it is an exchange, throw that exception - if it is a message, store as 'out' on the exchange-parameter - if it is something else, store it as body of the 'out' message So have you tried setting the header on the 'out' message? Jan > -----Ursprüngliche Nachricht----- > Von: Chris [mailto:cwolf.a...@gmail.com] > Gesendet: Mittwoch, 18. September 2013 22:58 > An: users@camel.apache.org > Betreff: How to set a header in custom DataFormat? > > I implemented a custom DataFormat and in the "unmarshal(Exchange > exchange, InputStream stream)" implementation I set a header, but upon > attempting to retrieve the header downstream from the "unmarshal" call, > the header is not there. Since the pattern is inOnly, I added the > header to the in Message. I've done similar with custom Processors and > in that case, it works. What is different with DataFormat? Is there > any way to set header(s) from DataFormat marshal/unmarshal? > > Thanks, > > Chris