Colin Schofield
Colin Schofield

Reputation: 167

How to define the Spring Integration errorChannel?

In a previous spring integration application, I was able to subscribe to the application errorChannel and my failed messages, sent out-bound, would end up in my (pre-defined) handler.

However, now I am attempting to implement the same pattern, in a larger application, that has a pre-existing in-bound setup and I am no longer able to be pick up on the errorChannel.

Most alarming to me, is a reference to:

<int:publish-subscribe-channel id="errorChannel" task-executor="errorChannelExecutor"/>

When I start up this application, with my inclusion, I no longer see the following reassuring messages:

No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
Adding {logging-channel-adapter:o.s.i.errorLogger} as a subscriber to the 'errorChannel' channel
Channel'o.s.c.s.C.errorChannel' has 2 subscriber(s).
  1. Do you think that the int:publish-subscribe-channel is overriding my access to the application errorChannel?
  2. Why does it no longer reference the default errorChannel in the log?
  3. Is there a way that I can define an alternate error channel that is solely concerned with out-bound connections?

Upvotes: 0

Views: 8115

Answers (1)

Gary Russell
Gary Russell

Reputation: 174799

When using async task executors, exceptions caught by the executor are sent to a channel called errorChannel by default.

If you define such a channel, it overrides the default which would otherwise be created by the framework (and the logging adapter that is subscribed to it, is not subscribed; you have to do that if you define your own channel).

For inbound channel adapters/gateways that are message-driven (e.g. http, amqp etc), where do don't have a downstream async executor, you have to explicitly set the error-channel property if you want exceptions to go there.

Upvotes: 4

Related Questions