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

Testing filters


We have defined a filter that filters out all messages except java feed. What is so special about filters that we want to discuss them separately? If you remember, filters always return a Boolean value, indicating whether to pass on the message or drop it, based on whether or not it satisfies the condition. For ease of reference, the following code snippet is the filter that we have defined:

import java.util.List;
import org.springframework.messaging.Message;
import com.sun.syndication.feed.synd.SyndCategoryImpl;
import com.sun.syndication.feed.synd.SyndEntry;

public class SoFeedFilter {
  public boolean filterFeed(Message<SyndEntry> message){
    SyndEntry entry = message.getPayload();
    List<SyndCategoryImpl>
      categories=entry.getCategories();
    if(categories!=null&&categories.size()>0){
      for (SyndCategoryImpl category: categories) {

        if(category.getName().equalsIgnoreCase("java")){
          return true;
        }

      }
...