Spring Book – Chapter 20 – Spring Integration


Most programs use data in one form or another, whether it is as input, output, or both. To bring data into a program, a Java program opens a stream to a data source, such as a file or remote socket, and reads the information serially. Spring Integration provides two adapters for reading from streams. They are:

  • org.springframework.integration.stream.ByteStreamReadingMessageSource for reading byte stream
  • org.springframework.integration.stream.CharacterStreamReadingMessageSource for reading character stream

Listing 22-38 below shows maven dependency required for integrating streams using Spring Integration.

Listing 22-38. Maven dependency required

Listing 22-39 below shows configuration of main Spring Integration namespace and stream related namespace in the Spring configuration file (stream-integration-context.xml).

Listing 22-39. Spring Integration Namespace declaration

Listing 22-40 below shows configuration of a basic stream adapter, both byte and character in the Spring configuration file (stream-integration-context.xml). Note that Spring Integration for stream doesn’t support namespace support for declaring these stream beans in the Spring configuration file.

Listing 22-40. Byte and Character stream bean configuration in Spring configuration file

For reading stream from system’s STDIN and for writing stream into system’s STDOUT, Spring Integration provides adapters and also has namespace support as well, as shown in Listing 22-41 below.

Listing 22-41. Declaring stdin and stdout stream adapters in Spring configuration file

Page Visitors: 13409

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.


Leave a Reply

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