org.springframework.integration.channel
Class AbstractPollableChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.channel.AbstractPollableChannel
- All Implemented Interfaces:
- BeanFactoryAware, BeanNameAware, InitializingBean, MessageChannel, PollableChannel, NamedComponent
- Direct Known Subclasses:
- QueueChannel
public abstract class AbstractPollableChannel
- extends AbstractMessageChannel
- implements PollableChannel
Base class for all pollable channels.
- Author:
- Mark Fisher
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, getSendErrorCount, getSendSuccessCount, send, send, setConversionService, setDatatypes, setInterceptors |
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
afterPropertiesSet, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getTaskScheduler, onInit, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setTaskScheduler, toString, writeMessageHistory |
AbstractPollableChannel
public AbstractPollableChannel()
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.
Copyright © 2010. All Rights Reserved.