--- 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. ![messagebus00][messagebus00] ## 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. Go to *Views* and select the *Message Sender* option. 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**. ![messagebus02][messagebus02] ## 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* view. 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. ![messagebus01][messagebus01] To clear the list of received messages, it is necessary to press the **Reset** button on the top right of the grid. [messagebus00]:./images/MessageBus00.gif [messagebus01]:./images/MessageBus01.png [messagebus02]:./images/MessageBus02.png