Book Image

Spring Integration Essentials

By : CHANDAN K PANDEY
Book Image

Spring Integration Essentials

By: CHANDAN K PANDEY

Overview of this book

Table of Contents (18 chapters)
Spring Integration Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Error handling on channels


Spring Integration supports synchronous as well as asynchronous message processing. In the case of synchronous processing, it is comparatively easy to handle error scenarios based on return values or by catching thrown exceptions; for asynchronous processing, things are more complicated. There are components provided by Spring, such as filters and routers, that can be used to validate message sanity and take action based on that. If it's invalid, the message can be routed to an invalid channel or a retry channel as the case may be. Apart from this, Spring provides a global error channel and capability to define custom error channels. The following points cover an appropriate error channel:

  • An error channel needs to be defined. This can be done as follows:

    <int:channel id="invalidMarksErrorChannel">
      <int:queue capacity="500"/>
    </int:channel>
  • A header named errorChannel needs to be added to the message. This is the name of the channel where ErrorMessage...