相关文章推荐
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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).
  • Do you think that the int:publish-subscribe-channel is overriding my access to the application errorChannel?
  • Why does it no longer reference the default errorChannel in the log?
  • Is there a way that I can define an alternate error channel that is solely concerned with out-bound connections?
  • Yes, it is overriding the default errorChannel with a pub-sub channel. Rename the pub-sub and you should be good. Wanna try that? – blurfus Sep 27, 2017 at 16:33 The thing is that the errorChannel is already defined so I cannot simply rename it in spring integration. Unless there is a way that I can use a different name for the error channel, specifically in my out-bound portion of the application? – Colin Schofield Sep 27, 2017 at 19:21 I meant renaming your pub-sub channel (the one in your question is the one you defined, right?) - not renaming the default errorChannel. – blurfus Sep 27, 2017 at 19:24 Thanks for replying - the pub-sub channel is pre-existing in-bound code. I would normally subscribe to the default channel for my out-bound section. Any other ideas? – Colin Schofield Sep 27, 2017 at 19:32

    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.

    So it is called the errorChannel by default, but there is a way to use a different name? We are using Kafka, specifically a KafkaProducerMessageHandler for our out-bound message flow. Can we simply rename the errorChannel there? – Colin Schofield Sep 27, 2017 at 19:29 No; the error channel goes on whatever starts the flow (e.g. gateway, inbound channel adapter); the outbound exception is caught and the ErrorMessage sent to the error channel. Or you can add an ExpressionEvaluatingRequestHandlingAdvice to the outbound adapter, but for the most part, downstream problems are handled on inbound endpoints. – Gary Russell Sep 27, 2017 at 21:09 Could you please point me at an example or some documentation for the ExpressionEvaluatingRequestHandlingAdvice? I take it that if I use this technique, I will be able to keep the in-bound and out-bound error handling completely separate. – Colin Schofield Sep 27, 2017 at 21:21 The retry-and-more sample has an example when using XML configuration. If you are using Java configuration, the adviceChain is on the @ServiceActivator; if using the Java DSL, the advice is on the endpoint spec. The ErrorMessage sent to the failure channel has an exception payload with the failed message, the cause, and the result of evaluating the expression. – Gary Russell Sep 27, 2017 at 21:31 Actually I had a quick look at the code, but I didn't see any reference to an ExpressionEvaluatingRequestHandlingAdvice. Are you sure you have the right example file? – Colin Schofield Sep 27, 2017 at 21:51

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid …

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

     
    推荐文章