此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Integration 6.3.1Spring中文文档

此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Integration 6.3.1Spring中文文档

Spring Integration的顶级接口定义如下:MessageChannelSpring中文文档

public interface MessageChannel {

    boolean send(Message message);

    boolean send(Message message, long timeout);
}

发送消息时,返回值为消息是否发送成功。 如果发送调用超时或中断,则返回 。truefalseSpring中文文档

PollableChannel

由于消息通道可能会也可能不会缓冲消息(如Spring Integration Overview中所述),因此两个子接口定义了缓冲(可轮询)和非缓冲(可订阅)通道行为。 以下列表显示了接口的定义:PollableChannelSpring中文文档

public interface PollableChannel extends MessageChannel {

    Message<?> receive();

    Message<?> receive(long timeout);

}

与 send 方法一样,在接收消息时,如果发生超时或中断,则返回值为 null。Spring中文文档

SubscribableChannel

基本接口由直接向其订阅的实例发送消息的通道实现。 因此,它们不提供用于轮询的接收方法。 相反,它们定义了管理这些订阅者的方法。 以下列表显示了接口的定义:SubscribableChannelMessageHandlerSubscribableChannelSpring中文文档

public interface SubscribableChannel extends MessageChannel {

    boolean subscribe(MessageHandler handler);

    boolean unsubscribe(MessageHandler handler);

}