2.3 MessageTarget

The MessageTarget interface defines a single method for sending Message objects.

public interface MessageTarget {
    boolean send(Message<?> message);
}

As with the MessageSource, Spring Integration also provides a MethodInvokingTarget adapter class.

MethodInvokingTarget target = new MethodInvokingTarget();
target.setObject(new TargetObject());
target.setMethodName("targetMethod");
target.afterPropertiesSet();
target.send(new StringMessage("test"));

When creating a Channel Adapter for this target, the corresponding XML configuration is very similar to that of MethodInvokingSource.

<channel-adapter channel="someChannel" target="targetObject" method="targetMethod"/>