org.springframework.integration.channel
Class AbstractPollableChannel

java.lang.Object
  extended by org.springframework.integration.channel.AbstractMessageChannel
      extended by org.springframework.integration.channel.AbstractPollableChannel
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, PollableChannel, MessageChannel
Direct Known Subclasses:
QueueChannel, ThreadLocalChannel

public abstract class AbstractPollableChannel
extends AbstractMessageChannel
implements PollableChannel

Base class for all pollable channels.

Author:
Mark Fisher

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannel
AbstractMessageChannel.ChannelInterceptorList
 
Constructor Summary
AbstractPollableChannel()
           
 
Method Summary
protected abstract  Message<?> doReceive(long timeout)
          Subclasses must implement this method.
 Message<?> receive()
          Receive the first available message from this channel.
 Message<?> receive(long timeout)
          Receive the first available message from this channel.
 
Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
addInterceptor, doSend, getInterceptors, getName, send, send, setBeanFactory, setBeanName, setConversionService, setDatatypes, setInterceptors, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.integration.channel.PollableChannel
clear, purge
 
Methods inherited from interface org.springframework.integration.core.MessageChannel
getName, send, send
 

Constructor Detail

AbstractPollableChannel

public AbstractPollableChannel()
Method Detail

receive

public final Message<?> receive()
Receive the first available message from this channel. If the channel contains no messages, this method will block.

Specified by:
receive in interface PollableChannel
Returns:
the first available message or null if the receiving thread is interrupted.

receive

public final Message<?> receive(long timeout)
Receive the first available message from this channel. If the channel contains no messages, this method will block until the allotted timeout elapses. If the specified timeout is 0, the method will return immediately. If less than zero, it will block indefinitely (see receive()).

Specified by:
receive in interface PollableChannel
Parameters:
timeout - the timeout in milliseconds
Returns:
the first available message or null if no message is available within the allotted time or the receiving thread is interrupted.

doReceive

protected abstract Message<?> doReceive(long timeout)
Subclasses must implement this method. A non-negative timeout indicates how long to wait if the channel is empty (if the value is 0, it must return immediately with or without success). A negative timeout value indicates that the method should block until either a message is available or the blocking thread is interrupted.