Class SyncMessageBus<T>
java.lang.Object
net.engio.mbassy.bus.AbstractPubSubSupport<T>
net.engio.mbassy.bus.SyncMessageBus<T>
- All Implemented Interfaces:
ErrorHandlingSupport, GenericMessagePublicationSupport<T, SyncMessageBus.SyncPostCommand>, PubSubSupport<T>, RuntimeProvider
public class SyncMessageBus<T>
extends AbstractPubSubSupport<T>
implements PubSubSupport<T>, ErrorHandlingSupport, GenericMessagePublicationSupport<T, SyncMessageBus.SyncPostCommand>
A message bus implementation that offers only synchronous message publication. Using this bus
will not create any new threads.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class AbstractPubSubSupport
ERROR_HANDLER_MSG -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor using default setup.SyncMessageBus(IBusConfiguration configuration) Construct with fully specified configurationSyncMessageBus(IPublicationErrorHandler errorHandler) Construct with default settings and specified publication error handler -
Method Summary
Modifier and TypeMethodDescriptionPublish a message to the bus using on of its supported message publication mechanisms.Synchronously publish a message to all registered listeners.Methods inherited from class AbstractPubSubSupport
createMessagePublication, getPublicationFactory, getRegisteredErrorHandlers, getRuntime, getSubscriptionsByMessageType, handlePublicationError, subscribe, toString, unsubscribeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ErrorHandlingSupport
getRegisteredErrorHandlersMethods inherited from interface PubSubSupport
subscribe, unsubscribeMethods inherited from interface RuntimeProvider
getRuntime
-
Constructor Details
-
SyncMessageBus
public SyncMessageBus()Default constructor using default setup. super() will also add a default publication error logger -
SyncMessageBus
Construct with default settings and specified publication error handler- Parameters:
errorHandler-
-
SyncMessageBus
Construct with fully specified configuration- Parameters:
configuration-
-
-
Method Details
-
publish
Description copied from interface:PubSubSupportSynchronously publish a message to all registered listeners. This includes listeners defined for super types of the given message type, provided they are not configured to reject valid subtype. The call returns when all matching handlers of all registered listeners have been notified (invoked) of the message.- Specified by:
publishin interfacePubSubSupport<T>- Parameters:
message-
-
post
Description copied from interface:GenericMessagePublicationSupportPublish a message to the bus using on of its supported message publication mechanisms. The supported mechanisms depend on the available implementation and are exposed as subclasses of IPublicationCommand. The standard mechanism is the synchronous dispatch which will publish the message in the current thread and returns after every matching handler has been invoked.- Specified by:
postin interfaceGenericMessagePublicationSupport<T, SyncMessageBus.SyncPostCommand>- Parameters:
message- - Any subtype of T welcome- Returns:
- An object that provides access to the available publication methods supported by the message bus.
-