2.2 MessageChannel

While the Message plays the crucial role of encapsulating data, it is the MessageChannel that decouples message producers from message consumers. Spring Integration's MessageChannel interface is defined as follows.

public interface MessageChannel {
    String getName();
    DispatcherPolicy getDispatcherPolicy();
    boolean send(Message message);
    boolean send(Message message, long timeout);
    Message receive();
    Message receive(long timeout);
}

The SimpleChannel implementation wraps a queue. It provides a no-argument constructor as well as a constructor that accepts the queue capacity:

public SimpleChannel(int capacity)

When sending a message, the return value will be true if the message is sent successfully. If the send call times out or is interrupted, then it will return false. Likewise when receiving a message, the return value will be null in the case of a timeout or interrupt.