Internet of Things Patterns
This is an excerpt of the pattern that was first published in [1].

Rules Engine

Icon of the Rules Engine pattern

You receive many different messages to which you want to react appropriately depending on the situation. Allow rules and associated actions to be defined. Compare all incoming messages against these rules and trigger the associated actions if a rule matches.

Aliases:

Action Engine, Trigger Conditions

Context:

A wide range of differing messages from devices and other components are received at the backend server. These might include measurements from sensors, errors, a heartbeat, registration information, etc. These messages can arrive regularly or irregularly. There are different kinds of actions that have to be executed depending on the type of the received message, its content, the time it is received, or other factors.

Problem:

Throughout its operation a system receives a wide range of messages from devices and other components. You want to react in different ways to these messages.

Forces:

  • Flexibility: The actions to trigger might change over time, new actions might be added, old ones removed, or you might want to temporarily test or disable an action. Hard-coding them into some software component would be possible, but is not flexible enough.

  • Data Sources: In some cases, additional data apart from the device message might be needed to decide if a particular action should be taken.

  • Diversity: The type of action to be triggered can vary significantly depending on the circumstances. In some cases, you might want to add an entry into a log file or send an email. In other cases, you might want to route a message to another service for further processing or store it in some kind of database.

Solution:

Pass all messages received from devices through a Rules Engine. Allow users to define rules using a graphical user interface that evaluate the content of incoming messages or metadata about the message against a set of comparators. Also allow external data sources to be included in these comparisons. Let users associate a set of actions with these rules. Apply each rule on each message and trigger the associated actions if a rule matches.

Solution sketch of the Factory Bootstrap pattern

Solution Details:

This is an excerpt of a previously published pattern. The full pattern can be found in [1].


Benefits:
Drawbacks:

Variants:

Related Patterns:

Known Uses:

  1. L. Reinfurt, U. Breitenbücher, M. Falkenthal, F. Leymann, and A. Riegg, “Internet of Things Patterns,” in Proceedings of the 21st European Conference on Pattern Languages of Programs (EuroPLoP), ACM, 2016. Available at http://dl.acm.org/citation.cfm?id=3011789