Spring Integration also provides adapters for streams. Both ByteStreamSource
and
CharacterStreamSource
implement the PollableSource
interface. By configuring one of these within a channel-adapter element, 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 MessageTarget
interface, they can be referenced from a
channel-adapter configuration as will be described in more detail in
Section 4.2.2, “Configuring Message Endpoints”.