Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Message Channels > Null Channel

Null Channel

The Null Channel is PollableChannel used primarily for testing purposes. The sending methods always return true, indicating the operation is successful, while the receiving methods always get a null message. Internally, the code does not create any queues, but returns true on a send operation or null on a receive operation immediately. For the complete picture (and if you are curious like me), see the actual implementation of the send and receive methods in the framework:

// This is the framework class implementation
public class NullChannel implements PollableChannel {
  // send will always return true
  public boolean send(Message<?> message) {
    if (logger.isDebugEnabled()) {
      logger.debug("message sent to null channel: " + message);
    }
    return true;
  }

  // receive will return null always
  public Message<?> receive() {
    if (logger.isDebugEnabled()) {
      logger.debug("receive called on null channel");
    }
    return null;
  }
...
}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial