Package net.engio.mbassy.bus
Class AbstractSyncAsyncMessageBus<T,P extends ISyncAsyncPublicationCommand>
- java.lang.Object
-
- net.engio.mbassy.bus.AbstractPubSubSupport<T>
-
- net.engio.mbassy.bus.AbstractSyncAsyncMessageBus<T,P>
-
- Type Parameters:
T
- The type of message this bus consumesP
- The publication commands this bus supports depend on P
- All Implemented Interfaces:
ErrorHandlingSupport
,GenericMessagePublicationSupport<T,P>
,IMessageBus<T,P>
,PubSubSupport<T>
,RuntimeProvider
- Direct Known Subclasses:
MBassador
public abstract class AbstractSyncAsyncMessageBus<T,P extends ISyncAsyncPublicationCommand> extends AbstractPubSubSupport<T> implements IMessageBus<T,P>
The base class for all message bus implementations with support for asynchronous message dispatch
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.Thread>
dispatchers
private java.util.concurrent.ExecutorService
executor
private java.util.concurrent.BlockingQueue<IMessagePublication>
pendingMessages
-
Fields inherited from class net.engio.mbassy.bus.AbstractPubSubSupport
ERROR_HANDLER_MSG
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSyncAsyncMessageBus(IBusConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IMessagePublication
addAsynchronousPublication(MessagePublication publication)
protected IMessagePublication
addAsynchronousPublication(MessagePublication publication, long timeout, java.util.concurrent.TimeUnit unit)
protected void
finalize()
boolean
hasPendingMessages()
Check whether any asynchronous message publications are pending to be processedprivate void
initDispatcherThreads(Feature.AsynchronousMessageDispatch configuration)
void
shutdown()
Shutdown the bus such that it will stop delivering asynchronous messages.-
Methods inherited from class net.engio.mbassy.bus.AbstractPubSubSupport
createMessagePublication, getPublicationFactory, getRegisteredErrorHandlers, getRuntime, getSubscriptionsByMessageType, handlePublicationError, subscribe, toString, unsubscribe
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.engio.mbassy.bus.common.ErrorHandlingSupport
getRegisteredErrorHandlers
-
Methods inherited from interface net.engio.mbassy.bus.common.IMessageBus
post
-
Methods inherited from interface net.engio.mbassy.bus.common.PubSubSupport
publish, subscribe, unsubscribe
-
Methods inherited from interface net.engio.mbassy.bus.common.RuntimeProvider
getRuntime
-
-
-
-
Field Detail
-
executor
private final java.util.concurrent.ExecutorService executor
-
dispatchers
private final java.util.List<java.lang.Thread> dispatchers
-
pendingMessages
private final java.util.concurrent.BlockingQueue<IMessagePublication> pendingMessages
-
-
Constructor Detail
-
AbstractSyncAsyncMessageBus
protected AbstractSyncAsyncMessageBus(IBusConfiguration configuration)
-
-
Method Detail
-
initDispatcherThreads
private void initDispatcherThreads(Feature.AsynchronousMessageDispatch configuration)
-
addAsynchronousPublication
protected IMessagePublication addAsynchronousPublication(MessagePublication publication)
-
addAsynchronousPublication
protected IMessagePublication addAsynchronousPublication(MessagePublication publication, long timeout, java.util.concurrent.TimeUnit unit)
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
shutdown
public void shutdown()
Description copied from interface:IMessageBus
Shutdown the bus such that it will stop delivering asynchronous messages. Executor service and other internally used threads will be shutdown gracefully. After calling shutdown it is not safe to further use the message bus.- Specified by:
shutdown
in interfaceIMessageBus<T,P extends ISyncAsyncPublicationCommand>
-
hasPendingMessages
public boolean hasPendingMessages()
Description copied from interface:IMessageBus
Check whether any asynchronous message publications are pending to be processed- Specified by:
hasPendingMessages
in interfaceIMessageBus<T,P extends ISyncAsyncPublicationCommand>
- Returns:
- true if any unfinished message publications are found
-
-