I use several service activators in a row in order to process some data. However, I have noticed that when a method that explicitly removes message headers is called via the service activator, SI simply replaces the removed headers before calling the next service. Looking at the source, this appears to be done in AbstractReplyProducingMessageHandler.createReplyMe ssage, which copies the request headers into the reply because shouldCopyRequestHeaders always returns true in the case of ServiceActivatingHandler.
I note that MessageTransformingHandler does not copy the request headers, however I cannot use this because it always expects a reply, and at compile time I don't know whether the underlying service will return a reply or not.
While copying the request headers makes sense for the use case of adding the request context to a reply from some external system, IMO it does not make sense if the returned value is already a Message as opposed to some other Object. Presumably if the returned value is a Message, the underlying service is SI-aware and would already have set the headers to the desired values.


Reply With Quote