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

A message bus implementation that offers only synchronous message publication. Using this bus will not create any new threads.
  • Constructor Details

    • 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 Details

    • 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 interface PubSubSupport<T>
      Parameters:
      message -
    • post

      public SyncMessageBus<T>.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 interface GenericMessagePublicationSupport<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.