--- alias: user-guide-message-bus description: "The Message Bus facilitates sending and subscribing to messages via a subject-based system" --- # Message Bus ## Overview :lock: Administration.**MessageBus**. Critical Manufacturing MES comes with a high-performance publish/subscribe message bus that implements a subject-based address system. The **Message Bus** page within the Administration page group provides access to the message bus functionality, allowing the sending of custom messages, normally used for testing purposes as well as the subscription to multiple subjects. === "Applications" ![Message Bus applications](./images/message_bus_applications.png) === "Message Listener" ![Message Bus Message Listener](./images/message_bus_message_listener.png) === "Message Sender" ![Message Bus Message Sender](./images/message_bus_message_sender.png) ## Subject Names The **Message Bus** uses a hierarchical subject name structure with the possibility of using wildcards. Each subject is formed by a sequence of tokens delimited by a dot ('.') as shown in the example below. ```sql Token1.Token2.Token3 ``` | Wildcard | Wildcard Definition | |----------|---------------------| | * | Can accept all values for one token, e. g. : A.*.B | | > | Accepts all values and tokens beyond the wildcard, e. g.: A.> | Table: Message Bus wildcards !!! info Subjects that start with CMF are reserved and must not be used by any application. Following this structure, each customer should come up with a naming structure convention that makes sense for their particular case. ## Sending Messages :lock: The Send Message functionality is associated with the security feature MessageBus.Publish. Messages are complex self-described structures. Messages can consist of simple scalar types or other messages, thus constructing nested messages. To send a message, it is necessary to follow the sequence: 1. Select the **Message Sender** tab. 2. Specify the **Type** of message - **Notification** or **Request**. * If the Message is a request for which a reply is expected, a **Timeout** must be specified. If the response is received within the specified timeframe, the reply is displayed on the right pane. 3. Optionally, enter the **Subject** of the Message. 4. Enter the **Message** and click **Send**. ![Message Bus Send Message tab showing subject input and message composition with Send button](./images/MessageBus02.png) ## Listening To Messages :lock: MessageBus.**Subscribe** Following the subject name structures and specifications described above, it is possible to subscribe to many subjects at the same time. To subscribe a subject, it is necessary to: 1. Go to the **Message Listener** tab. 2. Add the desired Subject to be listened to. 3. Press the **Add** button to add it to the list of registered subjects. To unsubscribe a subject, it is necessary to: 1. Select the subject to be unsubscribed from the list of registered subjects. 2. Press the **Remove** button to remove it. When there are active subjects being listened to, whenever a message is received, it will be placed in a list that can be accessed on the bottom-left pane of the **Message Listener** tab. Clicking on the message will display its contents on the message details pane on the right side. ![Message Bus Message Listener tab showing subscribed subjects list and received messages panel](./images/MessageBus01.png) To clear the list of received messages, it is necessary to press the **Reset** button on the top right of the grid.