2.2 MessageSource

The MessageSource interface defines a single method for receiving Message objects.

public interface MessageSource<T> {
    Message<T> receive();
}

Spring Integration also provides a MethodInvokingSource implementation that serves as an adapter for invoking any arbitrary method on a plain Object (i.e. there is no need to implement an interface). To use the MethodInvokingSource, provide the Object reference and the method name.

MethodInvokingSource source = new MethodInvokingSource();
source.setObject(new SourceObject());
source.setMethodName("sourceMethod");
Message<?> result = source.receive();

It is generally more common to configure a MethodInvokingSource in XML by providing a bean reference in the "source" attribute of a <channel-adapter> element.

<channel-adapter source="sourceObject" method="sourceMethod" channel="someChannel"/>