public abstract class AbstractSubscribableChannel extends Object implements SubscribableChannel, org.springframework.beans.factory.BeanNameAware
SubscribableChannel implementations.| Modifier and Type | Field and Description |
|---|---|
protected Log |
logger |
INDEFINITE_TIMEOUT| Constructor and Description |
|---|
AbstractSubscribableChannel() |
| Modifier and Type | Method and Description |
|---|---|
String |
getBeanName() |
protected abstract boolean |
hasSubscription(MessageHandler handler) |
boolean |
send(Message<?> message)
Send a
Message to this channel. |
boolean |
send(Message<?> message,
long timeout)
Send a message, blocking until either the message is accepted or the specified
timeout period elapses.
|
protected abstract boolean |
sendInternal(Message<?> message,
long timeout) |
void |
setBeanName(String name) |
boolean |
subscribe(MessageHandler handler)
Register a
MessageHandler as a subscriber to this channel. |
protected abstract boolean |
subscribeInternal(MessageHandler handler) |
boolean |
unsubscribe(MessageHandler handler)
Remove a
MessageHandler from the subscribers of this channel. |
protected abstract boolean |
unsubscribeInternal(MessageHandler handler) |
protected Log logger
public void setBeanName(String name)
Used primarily for logging purposes.
setBeanName in interface org.springframework.beans.factory.BeanNameAwarepublic String getBeanName()
public final boolean send(Message<?> message)
MessageChannelMessage to this channel. May throw a RuntimeException for
non-recoverable errors. Otherwise, if the Message cannot be sent for a non-fatal
reason this method will return 'false', and if the Message is sent successfully, it
will return 'true'.
Depending on the implementation, this method may block indefinitely. To provide a
maximum wait time, use MessageChannel.send(Message, long).
send in interface MessageChannelmessage - the Message to sendpublic final boolean send(Message<?> message, long timeout)
MessageChannelsend in interface MessageChannelmessage - the Message to sendtimeout - the timeout in milliseconds or #INDEFINITE_TIMEOUTtrue if the message is sent successfully, false if the
specified timeout period elapses or the send is interruptedprotected abstract boolean sendInternal(Message<?> message, long timeout)
public final boolean subscribe(MessageHandler handler)
SubscribableChannelMessageHandler as a subscriber to this channel.subscribe in interface SubscribableChanneltrue if the channel was not already subscribed to the specified
handlerprotected abstract boolean hasSubscription(MessageHandler handler)
protected abstract boolean subscribeInternal(MessageHandler handler)
public final boolean unsubscribe(MessageHandler handler)
SubscribableChannelMessageHandler from the subscribers of this channel.unsubscribe in interface SubscribableChanneltrue if the channel was previously subscribed to the specified
handlerprotected abstract boolean unsubscribeInternal(MessageHandler handler)