Stay organized with collections
Save and categorize content based on your preferences.
Create a source message class
This guide describes how to create a
source message class
for the Manufacturing Data Engine (MDE).
Source message class modelling
Source messages classes should be defined to capture a set of source messages that share a
common structure.
The more specific you design your source message classes, the fewer conditional
statements you need to write in your Whistle scripts to handle schema
differences between different source messages. However, creating more specific
source message classes comes at the expense of requiring more parsers.
Therefore, modeling source message classes involves finding the right balance
between, on one hand, having source message classes with uniform message schemas
and, on the other hand, the number of parsers you need to manage.
Source message class creation
This section outlines the process of creating a source message class using
either API calls or the console interface.
MESSAGE_CLASS_NAME: the name of the message class to be created.
PRIORITY: the priority of the message class. The priority of a message
class is an integer from 0 to 65535 , inclusive. Lower integers indicate
higher priorities.
SPEL_EXPRESSION: the SpEL expression defining the message class. For
example #root.event['value'] instanceof T(Number)
Console
Open the 'MESSAGE CLASSES' section of the UI to create
a Source Message Class. A list of all available Message Classes is
displayed in this section of the UI:
For each Message Class the following parameters are displayed in the List:
Message Class Name: the name of the Message Class. Has to be
unique.
Message Class Expression: the actual SpEL expression associated to
the Message Class.
Priority: the priority of the Message Class (lower numbers represent
higher priorities).
Enabled: the status of the message classes.
Disabled Message Classes won't be part of the ingestion.
Actions: a contextual button providing access to the 'View /
Edit' function and the 'Enable / Disable' functions for the
selected Message Class.
To add a new Message Class click the 'ADD NEW MESSAGE CLASS' button
at the top. A new side menu is displayed containing all the required
Message Class parameters to be provided:
Message Class Name: a unique String defining the Message Class.
Message Class Expression: refers to the SpEL expression defining the
message class.
Priority: defines the priority associated to the Message Class. The
priority of a message class is an integer from 0 to 65535 , inclusive.
Lower integers indicate higher priorities. If a messages validates the
expression of 2 Message Classes, only the one with the lower priority
value will be triggered.
To create a new Message Class fill in the Message Class Expression field
with a valid SpEL expression and set the priority
Click 'CREATE'
button to save the changes. A confirmation message is displayed if the new
Message Class is created successfully.
Testing a source message class expression
You can experiment and test your source message class expressions before
creating a source message class.
SPEL_EXPRESSION: the SpEL expression defining the message class.
TEST_MESSAGE: the test source message object.
The return object informs you whether the provided expression is
syntactically correct, and whether it would evaluate to true of false
for the provided message.
Console
The UI provides the option to test the SpEL expression of the new Message
Class with a test message.
Fill in the 'Test Message' box with the
sample JSON message.
Click 'RUN TEST' to run the validation. The
result of the test is a 'Matched' or 'Not matched' result and short
explanation of the matching criteria.
Evaluating a test message against all active message classes
You can evaluate a message to determine in which source message class a test
message would fall for a set of active source message classes.
REST
POST /configuration/v1/message-classes:evaluate
{"testMessage":"TEST_MESSAGE"}
Replace the following:
TEST_MESSAGE with the test source message object.
The return object informs you which source message class was matched for the
provided message, if any.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[],[],null,["# Create a source message class\n=============================\n\nThis guide describes how to create a\n[source message class](/manufacturing-data-engine/docs/concepts/source-message-class)\nfor the Manufacturing Data Engine (MDE).\n\nSource message class modelling\n------------------------------\n\nSource messages classes should be defined to capture a set of source messages that share a\ncommon structure.\n\nThe more specific you design your source message classes, the fewer conditional\nstatements you need to write in your *Whistle* scripts to handle schema\ndifferences between different source messages. However, creating more specific\nsource message classes comes at the expense of requiring more parsers.\n\nTherefore, modeling source message classes involves finding the right balance\nbetween, on one hand, having source message classes with uniform message schemas\nand, on the other hand, the number of parsers you need to manage.\n\nSource message class creation\n-----------------------------\n\nThis section outlines the process of creating a source message class using\neither API calls or the console interface.\n**Important:** As of MDE release 1.4.1 and later versions, the Pub/Sub message headers are stored in a reserved attribute called `mdeHeaders`. The existing message-classes from previous releases that used expressions like `#root.headers['SOME_ATTRIBUTE']` will continue to work for a limited number of future releases before it's deprecated. Make sure that you update your message-class expressions to use `#root.mdeHeaders['SOME_ATTRIBUTE']` instead. \n\n### REST\n\n`POST /configuration/v1/message-classes` \n\n {\n \"name\": \"\u003cvar translate=\"no\"\u003eMESSAGE_CLASS_NAME\u003c/var\u003e\",\n \"MESSAGE_CLASS_NAME\": \"\u003cvar translate=\"no\"\u003ePRIORITY\u003c/var\u003e\",\n \"expression\": \"\u003cvar translate=\"no\"\u003eSPEL_EXPRESSION\u003c/var\u003e\"\n }\n\nReplace the following:\n\n- `MESSAGE_CLASS_NAME`: the name of the message class to be created.\n- `PRIORITY`: the priority of the message class. The priority of a message class is an integer from 0 to 65535 , inclusive. Lower integers indicate higher priorities.\n- `SPEL_EXPRESSION`: the SpEL expression defining the message class. For example `#root.event['value'] instanceof T(Number)`\n\n### Console\n\n1. Open the **'MESSAGE CLASSES'** section of the UI to create\n a **Source Message Class** . A list of all available **Message Classes** is\n displayed in this section of the UI:\n\n For each Message Class the following parameters are displayed in the List:\n - **Message Class Name**: the name of the Message Class. Has to be unique.\n - **Message Class Expression**: the actual SpEL expression associated to the Message Class.\n - **Priority**: the priority of the Message Class (lower numbers represent higher priorities).\n - **Enabled**: the status of the message classes. Disabled Message Classes won't be part of the ingestion.\n - **Actions** : a contextual button providing access to the **'View /\n Edit'** function and the '**Enable / Disable'** functions for the selected Message Class.\n2. To add a new **Message Class** click the **'ADD NEW MESSAGE CLASS'** button\n at the top. A new side menu is displayed containing all the required\n **Message Class** parameters to be provided:\n\n - **Message Class Name**: a unique String defining the Message Class.\n - **Message Class Expression**: refers to the SpEL expression defining the message class.\n - **Priority**: defines the priority associated to the Message Class. The priority of a message class is an integer from 0 to 65535 , inclusive. Lower integers indicate higher priorities. If a messages validates the expression of 2 Message Classes, only the one with the lower priority value will be triggered.\n3. To create a new **Message Class** fill in the Message Class Expression field\n with a valid SpEL expression and set the priority\n\n4. Click **'CREATE'**\n button to save the changes. A confirmation message is displayed if the new\n Message Class is created successfully.\n\n| **Note:** At runtime, all active source message classes are sorted on priority, and for any given message, each message class expression is evaluated until one that evaluates to `true` is found. At that point, further message class evaluation stops.\n\nTesting a source message class expression\n-----------------------------------------\n\nYou can experiment and test your source message class expressions before\ncreating a source message class. \n\n### REST\n\n`POST /configuration/v1/message-classes:test` \n\n {\n \"expression\": \"\u003cvar translate=\"no\"\u003eSPEL_EXPRESSION\u003c/var\u003e\",\n \"testMessage\": \"\u003cvar translate=\"no\"\u003eTEST_MESSAGE\u003c/var\u003e\"\n }\n\nReplace the following:\n\n- `SPEL_EXPRESSION`: the SpEL expression defining the message class.\n- `TEST_MESSAGE`: the test source message object.\n\nThe return object informs you whether the provided expression is\nsyntactically correct, and whether it would evaluate to `true` of `false`\nfor the provided message.\n\n### Console\n\nThe UI provides the option to test the SpEL expression of the new Message\nClass with a test message.\n\n1. Fill in the **'Test Message'** box with the sample `JSON` message.\n2. Click **'RUN TEST'** to run the validation. The result of the test is a **'Matched'** or **'Not matched'** result and short explanation of the matching criteria.\n\nEvaluating a test message against all active message classes\n------------------------------------------------------------\n\nYou can evaluate a message to determine in which source message class a test\nmessage would fall for a set of active source message classes. \n\n### REST\n\n`POST /configuration/v1/message-classes:evaluate` \n\n {\n \"testMessage\": \"\u003cvar translate=\"no\"\u003eTEST_MESSAGE\u003c/var\u003e\"\n }\n\nReplace the following:\n\n- `TEST_MESSAGE` with the test source message object.\n\nThe return object informs you which source message class was matched for the\nprovided message, if any."]]