Package net.engio.mbassy.bus
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 Modifier and Type Class Description class
SyncMessageBus.SyncPostCommand
-
Field Summary
-
Fields inherited from class net.engio.mbassy.bus.AbstractPubSubSupport
ERROR_HANDLER_MSG
-
-
Constructor Summary
Constructors Constructor Description SyncMessageBus()
Default 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SyncMessageBus.SyncPostCommand
post(T message)
Publish a message to the bus using on of its supported message publication mechanisms.IMessagePublication
publish(T message)
Synchronously publish a message to all registered listeners.-
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, finalize, 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.PubSubSupport
subscribe, unsubscribe
-
Methods inherited from interface net.engio.mbassy.bus.common.RuntimeProvider
getRuntime
-
-
-
-
Constructor Detail
-
SyncMessageBus
public SyncMessageBus()
Default constructor using default setup. super() will also add a default publication error logger
-
SyncMessageBus
public SyncMessageBus(IPublicationErrorHandler errorHandler)
Construct with default settings and specified publication error handler- Parameters:
errorHandler
-
-
SyncMessageBus
public SyncMessageBus(IBusConfiguration configuration)
Construct with fully specified configuration- Parameters:
configuration
-
-
-
Method Detail
-
publish
public IMessagePublication publish(T message)
Description copied from interface:PubSubSupport
Synchronously 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:
publish
in interfacePubSubSupport<T>
-
post
public SyncMessageBus.SyncPostCommand post(T message)
Description copied from interface:GenericMessagePublicationSupport
Publish 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:
post
in 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.
-
-