Spring Integration Tutorial (Part 3) - Filters

12,174 views

Published on

In Part 3 of our Spring Integration tutorial series we take a look at another message endpoint - the filter. Filters sit between message channels.

Filters allow, on the basis of a message's content or metadata (in the message header), a message to pass from one channel to the next or reject and discard the message from the system - that is, not allowing the rejected message into the next channel. The filter is a "yea or nay" component determining which messages flow through and which messages do not.

In this third part of the tutorial series, you explore the types and configuration of filters provided by Spring Integration and how to create your own custom filter using a Spring Integration MessageSelector interface.

Published in: Software
1 Comment
3 Likes
Statistics
Notes
No Downloads
Views
Total views
12,174
On SlideShare
0
From Embeds
0
Number of Embeds
10,143
Actions
Shares
0
Downloads
137
Comments
1
Likes
3
Embeds 0
No embeds

No notes for slide

Spring Integration Tutorial (Part 3) - Filters

  1. 1. Copyright © 2014 by Intertech, Inc.
  2. 2. Copyright © 2014 by Intertech, Inc.
  3. 3. Copyright © 2014 by Intertech, Inc.
  4. 4. Copyright © 2014 by Intertech, Inc.
  5. 5. Copyright © 2014 by Intertech, Inc. <int:filter input-channel="inboundChannel" output-channel="outboundChannel" expression="payload.startsWith('Hello')" /> <int:filter input-channel="inboundChannel" output-channel="outboundChannel" discard-channel="relook-channel" expression="payload.startsWith('Hello')" />
  6. 6. Copyright © 2014 by Intertech, Inc. public class MySelector implements MessageSelector { public boolean accept(Message<?> message) { if (message.getPayload() instanceof String && ((String) message.getPayload()).startsWith("Hello")) return true; return false; } }
  7. 7. Copyright © 2014 by Intertech, Inc. <int:filter input-channel="inboundChannel" output-channel="outboundChannel" ref="selector" /> <bean id="selector" class="com.intertech.MySelector" />
  8. 8. Copyright © 2014 by Intertech, Inc. Click here for associated labs and video
  9. 9. Copyright © 2014 by Intertech, Inc. http://bit.ly/1hyrViM

×