public abstract class AbstractSubscribableChannel extends java.lang.Object implements SubscribableChannel, BeanNameAware
SubscribableChannel
implementations.Modifier and Type | Field and Description |
---|---|
private java.lang.String |
beanName |
protected Log |
logger |
INDEFINITE_TIMEOUT
Constructor and Description |
---|
AbstractSubscribableChannel() |
Modifier and Type | Method and Description |
---|---|
java.lang.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(java.lang.String name)
Set the name of the bean in the bean factory that created this bean.
|
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) |
public void setBeanName(java.lang.String name)
Invoked after population of normal bean properties but before an
init callback such as InitializingBean.afterPropertiesSet()
or a custom init-method.
Used primarily for logging purposes.
setBeanName
in interface BeanNameAware
name
- the name of the bean in the factory.
Note that this name is the actual bean name used in the factory, which may
differ from the originally specified name: in particular for inner bean
names, the actual bean name might have been made unique through appending
"#..." suffixes. Use the BeanFactoryUtils.originalBeanName(String)
method to extract the original bean name (without suffix), if desired.public java.lang.String getBeanName()
public final boolean send(Message<?> message)
MessageChannel
Message
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 MessageChannel
message
- the Message
to sendpublic final boolean send(Message<?> message, long timeout)
MessageChannel
send
in interface MessageChannel
message
- 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)
SubscribableChannel
MessageHandler
as a subscriber to this channel.subscribe
in interface SubscribableChannel
true
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)
SubscribableChannel
MessageHandler
from the subscribers of this channel.unsubscribe
in interface SubscribableChannel
true
if the channel was previously subscribed to the specified
handlerprotected abstract boolean unsubscribeInternal(MessageHandler handler)