Action Service¶
1. Introduction¶
TCUP Action Service is a rule based service which allows users to execute or invoke different types of actions (such as web service invocation, sending notification or alert, storing events in the database etc.) when certain events or conditions are detected on incoming message data from Message Routing or Complex Event Processing services. The different type of actions are web service invocation, sending notification or alert to Android or iOS phone, storing events in external database etc. Action Service allows application developers to use predefined action template or to define any custom action type and invoke RESTful APIS of other TCUP Services as well.
1.1 Intended Audience¶
The intended audience of this document is anyone who wants to have an overview of TCUP Action Service. After going through this document, the user will understand the capability of TCUP Action Service in IoT platform.
2. Key Concepts¶
In order to use Action Service, a user needs to understand some basic concepts and building blocks of the service. Please refer to the following section for the concepts:
2.1 Action Type¶
Action type refers to various actions that can be performed via Action Service. It provides the template of the action which can be performed through a rule. There are two types of templates namely:
Pre-defined Action Types – Users can use the following templates that are pre-built in the service as listed below:
RDBMS write
REST API Invocation
Push notification to android phone
Writing to Elastic Search DB (to transform data to Elastic Search format Jolt schema is used)
Writing to syslog (Linux utility)
Posting data to TCUP SOS
Store parquet format data into HDFS
Stream summary on incoming data stream
Poll a REST API in a given schedule
Custom Action Types – Apart from predefined actions, application developers/ users can develop their own custom action type and get it deployed in TCUP Action Service.
2.2 Action Rule¶
Action rules are user defined configuration parameters based on which Action Service performs action using the data received from topic, message queue or direct exchange. Action rule has its own input section where users can define input from where Action Service will receive data. Users can also provide required parameters while defining an action rule.
2.3 Mobile Device User¶
The users can use these APIs to register, describe, update or delete mobile devices. Once mobile device is registered, users will start receiving corresponding push notifications.
3. Functional Capabilities¶
Action Service provides the following functional capabilities:
Allows to create rules for predefined action type as below:
Allows to insert data into a table of an external database. It also supports batch insertion to database over scheduled operation.
Inserts data into TCUP Sensor Observation Service (SOS).
Send event alert to user mobile
Insert data in TCUP Data Explorer service.
Sending email.
To aggregate data in a compressed file format (parquet files) and store the same in Hadoop file system.
Parquet file can also be stored to Amazon S3 storage.
Metadata of parquet file like name, location etc of this file can be stored in Data Lake Service to retrieve in future.
To calculate stream summary or aggregate functions like minimum, maximum, average, count of incoming data stream.
To poll an external web service based data source (HTTP/HTTPS) in a given schedule, take required action over that data and publish the fetched data into TCUP messaging layer.
Post data in the external web service.
Allows to support time/count based scheduling i.e. the required action will be performed after certain time interval or after certain number of event occurs.
Default round robin routing algorithm is used for routing the messages inside rule. User can also set “Consistent Hashing Routing” algorithm, in order to group and process by sensor name so that all the messages generated from a sensor gets processed by a single consumer instead of getting distributed amongst all the consumers.
Facilitates to view run-time status of a rule.
Allows to query action type which returns all the parameters of the defined action type.
Allows to delete an action type
Allows to define custom action type and deploy and update the same.
Supports for event format transformation ie this service is capable to format the output in a way which is suitable for destination application
Allows to view rule statistics overview, rule message processing statistics,
4. Purpose/Usage¶
Action Service is a key component of TCUP since it provides a powerful distributed environment to perform different actions based on analysis of data harvested from sensors. Action Service is used to take data from various input like TCUP MR Service, CEP service, 3rd Party webservice etc. as input and process those as required based on action rule,
Some of the common usage patterns are as follows:
Integrating with any third party services whose data format does not comply with TCUP data format. The data from the third party can be obtained in different formats like JSON, text, zip etc. and Action Service enables it to be transformed or converted into uniform format or the structure of the data can be changed before feeding into downstream applications.
To view the graphical representation of sensor observation data – Action Service can be leveraged to act as a bridge between Sensor Observation Service to TCUP Data Explorer Service so that the data from the former service is in sync with the latter. Then the user will able to view the data graphically from TCUP Data Explorer Service.
Alert notification to caregiver in a smart home system - Consider the situation where a movement monitoring sensor is attached to an elderly person to detect his movement. Alert notification is required to be sent to the caregiver when there is no movement detected over 30 minutes. This service can be used to send SMS notification to the caregiver’s mobile when the absence of movement is detected.
Sending machine throughput report for a manufacturing plant to management. Consider the case where multiple PCB fabrication machine is installed in a factory and is sending events continuously for each PCB fabrication. It is required to calculate the throughput of each machine to track how many PCB gets fabricated each day. Message Routing is used to keep counter of each machine for every throughput and emits updated throughput every time an event gets generated from the machine. At the end of the day, Action Service is used to send the count via email to the management and then the counter gets reset.
5. Examples¶
Consider an example of an Engine Monitoring System. The engine has an Engine Control Unit (ECU) attached and this ECU is connected to a gateway via the Controller Area Network (CANbus) system. The gateway is connected to TCUP via a wireless internet connection. The gateway runs an embedded Linux operating system. The system needs to send an alert notification to designated users’ mobile phone when the temperature of the engine crosses a certain threshold value.
A data acquisition software is running on the gateway. This software uses Sensor Observation Service to push data to TCUP cloud. The application is modelled in TCUP as follows:
Sensor Observation Service will publish the data to Message Routing service.
Message Routing will filter temperature data based on threshold value.
Action Service will get that filtered data and send alert to the user’s mobile using push notification action type.
6. Reference Document¶
Please refer to the following documents for more details about this service:
API Guide