Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the new function of EMQ X Enterprise Rule Engine

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

EMQ X Enterprise new function Rule Engine how to understand, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

EMQ X Enterprise Rule Engine

RuleEngine (hereinafter referred to as the rules engine) is used to configure the rules for handling and responding to EMQ X message flows and device events. As a new heavyweight feature of EMQ X in 2019, the rules engine not only provides a clear and flexible "configuration" business integration solution, which is used to simplify business development processes, improve user ease of use, and reduce the coupling between business systems and EMQ X. it also provides a better infrastructure for EMQ X private function customization and improves development delivery speed.

The open source version of the rules engine provides basic processing power and has been released in EMQ X v3.1.0. A more flexible and customized rule engine is being developed and tested closely, and the integration is planned for release in the next commercial version of EMQ X.

Examples of typical application scenarios of rule engine:

Action monitoring: in the development of smart home intelligent door lock, the function of the door lock will be abnormal due to network, power failure, man-made damage and other reasons. Use the rule engine configuration to monitor offline events and push the fault information to the application service. The ability to detect faults in the first time can be realized in the access layer.

Data filtering: the truck fleet management of the vehicle network, the vehicle sensor collects and reports a large number of running data, and the application platform only pays attention to the data when the speed is greater than 40 km/h. In this scenario, the rule engine can be used to conditionally filter messages and write qualified data to the business message queue.

Message routing: in intelligent billing applications, terminal devices distinguish business types by different topics. By configuring the rule engine, the message of the billing service can be accessed into the billing message queue and sent to the business system after the message arrives at the device. Non-billing information is connected to other message queues to achieve business message routing configuration.

Message codec: in other public / private TCP protocol access, industrial control industry and other application scenarios, you can use the local processing function of the rules engine (which can be customized and developed on EMQ X) to do the encoding and decoding of binary / special format messages. You can also flow relevant messages to external computing resources such as function calculation for processing through message routing of the rule engine (processing logic can be developed by users), and convert messages to JSON format that is easy for business to handle, thus simplifying project integration and improving the ability of rapid application development and delivery.

Schematic diagram of Rule Engine

The rule engine filters, transforms and enriches the data embedded in the message forwarding process of EMQ to achieve efficient data processing. The new rule engine covers the functions of multiple plug-ins in EMQ X, centrally manages the independent external resources in the original plug-in, realizes resource reuse, and reduces the complexity of management and monitoring. At the same time, the rules engine builds most of the calculations that can only be carried out on the application side into EMQ X to improve the efficiency of message processing by calculating, filtering and filtering high-value data, while simplifying the business architecture, reducing the data transmission path and reducing the message processing delay.

Features related to the rules engine include:

Message rules: processing messages from devices to EMQ X, implementing conditional calculation and filtering, message structure adjustment, message republishing, persistence and bridging

Event rules: deal with each event information in the device communication life cycle, which can easily realize the functions of device status record, such as online and offline notification, authentication connection record, message status record, such as message billing statistics, etc.

Resource management: centrally manage external resources, realize resource reuse, and reduce the complexity of management and monitoring.

Like other functions of EMQ X, the rule engine also provides similar HTTP REST API to facilitate user application development integration, and the visual creation, editing and management functions of the rule engine are also realized in EMQ X Dashboard (EMQ X Management console).

Message rule

With the message rules in the rules engine, users can route or write messages from the device to EMQ X to various databases, message queues, HTTP REST gateways and other objects or resources, or resend them to the device to achieve server-side computing functions.

The rules engine provides data query and processing functions based on SQL expressions, allowing you to filter the data and convert the message to a preset format before configuring subsequent processing actions.

Examples of SQL expressions are as follows:

-- Select the name field in the body of the message sent to the "EMQ'select payload.name as name from a" topic, and filter it as follows: name = 'EMQ'select payload.name as name from "t bind a" when name =' EMQ'-- selects the message body select payload from "command/#" to the "command/#" topic

Typical features and application scenarios of message rules are as follows:

Filter by the topic of the message, specify the message to be processed, and republish to the new topic after processing

Make the filter condition, filter the condition according to the specific field of the message body, and process the data that meet the condition

Convert the message body into a preset structure for reprocessing, reducing internal communication and external storage and computing overhead

Message digest, transcoding, mathematical operation and other preprocessing methods are used to deal with the message body or the specified fields in the message body, and the simple calculation is completed in Broker to reduce the operation delay.

Each message rule contains the following attributes:

Attribute describes the source of the data flow to be processed by Source. Based on the MQTT topic, the FROM directive filter condition in SQL is used to filter expressions for message body (JSON information only) and message context information (such as QoS, Client ID, Username) to determine the matching condition and message structure of the rule. The WHERE instruction query processor in SQL is used to select and preprocess the specified data according to the selection expressions of message body (JSON information only) and message context information (such as QoS, Client ID, Username). The rule engine has built-in a variety of preprocessing methods, such as message digest, codec and encoding conversion, simple mathematical operation, and processing using SQL clauses and SQL functions. The actions that need to be triggered after the action message hits the rule and is processed successfully, specify the specific action operations, such as writing database SQL statements, objects and topics sent to the message queue. A rule can define one or more actions to achieve multi-end processing of the rule. Event rule

With the event rules in the rule engine, users can process each event information in the device communication lifecycle. Typical features and application scenarios of event rules are as follows:

Each event action log:, of the device, such as device connection / disconnection, message publishing, message delivery / arrival / discard, device subscription / unsubscription, etc., for device operation record and behavior analysis.

Device online and offline notification and recording: monitoring client.connected and client.disconnected events can achieve device online and offline recording

Message status record: you can monitor the status of key message instructions such as successful / failed callbacks by listening to message-related events.

Attached: the function list of the rules engine describes the basic features of the open source commercial version

Conditional filtering carries on conditional filtering through event name, context information and message content. Message flow to be processed supports preprocessing to realize simple mathematical calculation, character processing, codec ability of message through built-in processing function. Output preformatted message supports resource management to realize simple mathematical calculation, character processing, codec ability of message through built-in processing function. Output message support in preset format

Message output

Publish to a specified topic republish the message processed by the rule (republish) to the specified topic for loading processing or for subscribers to use support to send messages to WebHook publish messages to HTTP API gateways support sending to message queues support private or public cloud message middleware such as Kafka, RabbitMQ, etc.

Support writing to private or public cloud databases including MySQL, PostgreSQL, MongoDB, Redis, etc.

Support for sending to another MQTT Broker to publish messages to another MQTT Broker-specified topic over the MQTT protocol, including but not limited to EMQ X, Azure IoT Hub, AWS IoT, Ali Cloud Internet of things platform

Support

Extended customization

Custom built-in processing functions, flexible handling of private protocols and special encoded messages

Custom private message output mode is supported, and the rule output side is more flexible.

Is it helpful for you to read the above content after reading it? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report