.. currentmodule:: event_collector.messagebus Message Bus =========== **Source code:** `event_collector.messagebus.py` .. py:module:: event_collector.messagebus This module implements a message bus used internally between the CollectorQueue and other components. .. pull-quote:: The *MessageBus* allows one component of the event-collector system to listen to messages or *bus events* emitted by other components without explicit tight coupling. MessageBus classes ------------------ .. autoclass:: event_collector.messagebus.Message ``Message`` is a generic base class for a bus message. .. autoclass:: event_collector.messagebus.Command ``Command`` is a generic base class for a bus command. .. autoclass:: event_collector.messagebus.MessageBus The message bus works by dispatching messages or commands to handlers. A ``MessageBus`` instance is initialized with a set of ``MsgHandlers`` and ``CmdHandlers``. Components define subclasses of ``Message`` or ``Command`` and dispatch or publish these events through the message bus. For each message or command, the message bus will check if any message or command handlers are registered to listen to the events. If a handler is registered, the bus will call the handler function when the message or command is triggered by the "dispatch" method. The ``CollectorQueue`` emits a set of ``Messages`` that your application can listen to. These are documented in the (:py:mod:`~event_collector.queue`) module.