public abstract class AbstractDispatcher extends java.lang.Object implements MessageDispatcher
MessageDispatcher implementations.
The subclasses implement the actual dispatching strategy, but this base class
manages the registration of MessageHandlers. Although the implemented
dispatching strategies may invoke handles in different ways (e.g. round-robin
vs. failover), this class does maintain the order of the underlying
collection. See the OrderedAwareCopyOnWriteArraySet for more detail.
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.logging.Log |
logger |
| Constructor and Description |
|---|
AbstractDispatcher() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addHandler(org.springframework.messaging.MessageHandler handler)
Add the handler to the internal Set.
|
int |
getHandlerCount()
Return the current handler count.
|
protected java.util.Set<org.springframework.messaging.MessageHandler> |
getHandlers()
Returns an unmodifiable
Set of this dispatcher's handlers. |
boolean |
removeHandler(org.springframework.messaging.MessageHandler handler)
Remove the handler from the internal handler Set.
|
void |
setMaxSubscribers(int maxSubscribers)
Set the maximum subscribers allowed by this dispatcher.
|
java.lang.String |
toString() |
protected boolean |
tryOptimizedDispatch(org.springframework.messaging.Message<?> message) |
protected java.lang.RuntimeException |
wrapExceptionIfNecessary(org.springframework.messaging.Message<?> message,
java.lang.Exception e)
Deprecated.
in favor of
IntegrationUtils#wrapInDeliveryExceptionIfNecessary(Message, Supplier, Exception) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdispatchpublic void setMaxSubscribers(int maxSubscribers)
maxSubscribers - The maximum number of subscribers allowed.protected java.util.Set<org.springframework.messaging.MessageHandler> getHandlers()
Set of this dispatcher's handlers. This
is provided for access by subclasses.public boolean addHandler(org.springframework.messaging.MessageHandler handler)
addHandler in interface MessageDispatcherhandler - The handler to add.Set.add(Object)public boolean removeHandler(org.springframework.messaging.MessageHandler handler)
removeHandler in interface MessageDispatcherhandler - the handler.Set.remove(Object)protected boolean tryOptimizedDispatch(org.springframework.messaging.Message<?> message)
@Deprecated
protected java.lang.RuntimeException wrapExceptionIfNecessary(org.springframework.messaging.Message<?> message,
java.lang.Exception e)
IntegrationUtils#wrapInDeliveryExceptionIfNecessary(Message, Supplier, Exception)MessagingException or does not have a
failedMessage, wrap it in a new
MessagingException with the message. There is some inconsistency here in
that MessagingExceptions are wrapped in a MessagingException whereas
Exceptions are wrapped in MessageDeliveryException. It is retained
for backwards compatibility and will be resolved in 5.1.
It also does not wrap other RuntimeExceptions.
TODO: Remove this in favor of
#wrapInDeliveryExceptionIfNecessary(Message, Supplier, Exception) in 5.1.message - the message.e - the exception.public java.lang.String toString()
toString in class java.lang.Objectpublic int getHandlerCount()
MessageDispatchergetHandlerCount in interface MessageDispatcher