I have almost similar use case in my current application. here is how I will do this (of course there would be better ways! )
1.
<jms:message-driven-channel-adapter
id="jmsIn" connection-factory="connectionFactory" message-converter="pubSubConverter"
destination-resolver="jmsDestinationResolver" destination="queueDestination"
channel="pubsubContextActivatorChannel" />
Using the pubSubConverter I am unmarshalling the response coming from queueDestination.
2. Since the message is to be audited after putting on the queue, I will put a wiretap around this channel, and there I will send it to queue. Something like:
Code:
<channel id="pubsubContextActivatorChannel">
<interceptors>
<wire-tap channel="toJMSChannel" />
</interceptors>
</channel>
3. Then, an activator on toJMSChannel for converting to whatever format, and passing it to exampleChannel:
Code:
<service-activator ref="convertToJMS"
method="whatever" input-channel="toJMSChannel"
output-channel="exampleChannel" />
<jms:outbound-channel-adapter id="jmsOut" destination="outQueue" channel="exampleChannel"/>
4. Lastly, after this has completed, I will audit:
Code:
<service-activator ref="auditBean"
method="writeToDBnFile" input-channel="pubsubContextActivatorChannel"
output-channel="finalChannel" />
If I use direct channels everywhere, this all would happen in the same thread, and the audit / writing to file would happen only after the message been sent to queue. Again, there might be better ways of doing this.