3.9 Stream Adapters

Spring Integration also provides adapters for streams. Both ByteStreamSource and CharacterStreamSource implement the Source interface. By configuring one of these within a SourceEndpoint, the polling period can be configured, and the Message Bus can automatically detect and schedule them. The byte stream version requires an InputStream, and the character stream version requires a Reader as the single constructor argument. The ByteStreamSource also accepts the 'bytesPerMessage' property to determine how many bytes it will attempt to read into each Message.

For target streams, there are also two implementations: ByteStreamTarget and CharacterStreamTarget. Each requires a single constructor argument - OutputStream for byte streams or Writer for character streams, and each provides a second constructor that adds the optional 'bufferSize' property. Since both of these ultimately implement the Target interface, they can be referenced from a TargetEndpoint configuration as will be described in more detail in the section called “Configuring Message Endpoints”.