Currently, one of the steps in processing messages takes some data about the message and stores it in a "job context" using ThreadLocals, ala SecurityContextHolder. I'm looking for a clean way to clear that context at the end of processing, regardless of how the processing ends (exception, outbound JMS, another gateway).

It seems like it should be possible to do this, without hooking everything into an explicit channel, but I seem to be missing something. Perhaps the only way to do this IS with an explicit channel (maybe a pub-sub for each path where the message ends)? Seems a little cumbersome though.