Reputation: 13501
Is it possible to configure an interceptor in Spring Integration to specify a logging message?
This is in contrast to using a wire-tap to send the message to a logging channel to which a logging channel adapter subscribes. The problem with this approach is that the logging channel has the expression for what exactly to log. In my use case I'd like to use a global channel-interceptor to specify a logging message and send it to a logging channel adapter, rather than having to define a logging channel adapter for every possible logging message I might want.
For a moment I thought I could define a service activator with an SpEL expression to produce the string logging message (and with an output-channel of the deisred logging channel) inside a channel-interceptor definition, but it's looking for an input-channel.
Upvotes: 0
Views: 1758
Reputation: 174739
Instead of using a wire-tap, you could make the channels you are interested in <publish-subscribe-channel/>
s.
Subscribe the appropriate transformer to the channel (with an output-channel
going to the logging adapter).
You can control whether the log happens before or after the real subscriber using the order
attribute on the transformer and other subscriber.
Another alternative is a global interceptor that adds a header to the message
MessageBuilder.fromMessage(message).setHeader('foo', routeForThisMessageType).build()
Then send it to a <header-value-router/>
which, in turn, routes to the appropriate transformer, and thence to the single logging channel adapter.
Of course, if you want, you can combine the routing and/or transforming right into the interceptor.
Upvotes: 1