Spring Book – Chapter 20 – Spring Integration

Filter

Message filters are entrusted with the decision of whether to pass or drop a message received. In Java this is implemented as Boolean method in which if it is “true” message will be passed through and if it is “false” the message will be dropped.

In EAI, message filter can be pictorially represented as shown in Figure 22-22 below.

Figure 22-22. Filter

Figure 22-22. Filter

Listing 22-13 below shows both Java code and the corresponding Spring configuration for declaring a filter endpoint in your application.

Listing 22-13. Java and Spring configuration for filter declaration

The default behaviour of filter is to silently drop the message if nothing is explicitly specified. There are other alternatives as shown below:

  • Upon message rejection throw exception as shown in Listing 22-14 below in Spring configuration file.

Listing 22-14. Throw exception when message is rejected (Spring configuration)

  • Send rejected message to discard channel as shown in Listing 22-15 below in Spring configuration file. Doing so makes such filters 2-way router or a switch.

Listing 22-15. Rejected message routed to discard channel

Splitter

A single message is taken in as input and the endpoint makes it split as multiple messages and sends these messages as output.

In EAI, message splitter can be pictorially represented as shown in Figure 22-23 below.

Figure 22-23. Splitter

Figure 22-23. Splitter

The splitting strategy should be specifically provided as separate method as shown in the Listing 22-16 below.

Listing 22-16. Splitter method in Java and corresponding Spring configuration

Page Visitors: 13341

The following two tabs change content below.
Tomcy John

Tomcy John

Blogger & Author at javacodebook
He is an Enterprise Java Specialist holding a degree in Engineering (B-Tech) with over 10 years of experience in several industries. He's currently working as Principal Architect at Emirates Group IT since 2005. Prior to this he has worked with Oracle Corporation and Ernst & Young. His main specialization is on various web technologies and acts as chief mentor and Architect to facilitate incorporating Spring as Corporate Standard in the organization.
Tomcy John

Latest posts by Tomcy John (see all)

2 thoughts on “Spring Book – Chapter 20 – Spring Integration

  1. Hi,
    Thanks for this blog and information sharing!
    I have one question from Spring Integration. Just thought of checking with you.
    I have SimplewebserviceOutBoundGateway. I need to send a document / attachment to the webservice. How will i achieve that?
    This is my current gateway configuration:

    Please let me know, if you can throw some light in this area.
    Thanks in Advance!

  2. Hi,
    Thank you for your information sharing.
    I have one doubt,could you please suggest me the correct frameworks to address that issue.

    My requirement is I would like to get and process files using spring and camel.

    Thanks,
    Madhu

Leave a Reply

Your email address will not be published. Required fields are marked *