Spring Integration

org.springframework.integration.channel
Class AbstractPollableChannel

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.channel.AbstractMessageChannel
          extended by org.springframework.integration.channel.AbstractPollableChannel
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, NamedComponent, PollableChannel, TrackableComponent, MessageChannel
Direct Known Subclasses:
QueueChannel

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
 
Field Summary
 
Fields inherited from class org.springframework.integration.channel.AbstractMessageChannel
logger
 
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, getComponentType, getInterceptors, send, send, setConversionService, setDatatypes, setInterceptors, setShouldTrack
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setComponentName, setTaskScheduler, 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.MessageChannel
send, send
 
Methods inherited from interface org.springframework.integration.context.NamedComponent
getComponentName
 

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.


Spring Integration