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

Persisting and recovering channels


We talked about all kind of channels, but if you have noticed, these are all in memory. What if the system crashes? No one wants to lose data. This is where persistent QueueChannel comes into the picture—messages will be backed up in the database defined by the data source. If the system crashes, then on recovery, it will pull all the messages in the database and queue them for processing. This is achieved in Spring using MessageGroupStore. Let's have a quick look at the configuration:

<int:channel id="resultPersistenceChannel">
  <int:queue message-store="messageStore"/>
</int:channel>

<int-jdbc:message-store id="messageStore" data-source="someDataSource"/>

Here, the message store is mapped to the database defined by someDataSource. When a message arrives, it will now be added to MessageStore first. On successful processing, it will be removed from there.

The moment we talk of databases, transaction comes into the picture. So what...