New Features

Subscription Support

By now you may already know that the Onesait Platform has a Data-Centric (focused on data) architecture, where data is the main asset and we treat it as ontologies. The ontologies are the entities that the system manages, and all the functionalities are based on this concept.

One of the novelties that version 2.0.0 (fireball) brings is support for ontology subscriptions.

This functionality allows a Platform client to subscribe to certain changes in a certain ontology, so that, when certain conditions are met, the Platform will notify that client about it.

In the Platform, we will have registered a subscription that will be associated with an ontology. In this subscription we will define:

  • Query field: the ontology field to which we want to subscribe.
  • Query operator: the type of operation to check.
  • Projection: the data that will be notified to the client.

On the other hand, the client will use the Java library provided by the Platform to subscribe via REST or MQTT to the subscription registered in the control panel. When subscribing, she must indicate the queryValue parameter.

Therefore, the complete data flow would be as follows:

  1. New data is inserted in an ontology that has a subscription associated with it.
  2. The system checks whether there are clients subscribed to said subscription, and whether the inserted data meets the condition of any of the subscribers.
  3. If that this condition is met, then the data defined by the “projection” field is notified to the client.

Let’s see a practical example below to better understand how it works.

Imagine that we have the Ticket ontology that generates instances with the following JSON format:

{"Ticket": {
            "identification": "ticket01",
            "status": "DONE",
            "email": "iex@email.com",
            "name": "Alberto",
            "response_via": "email",
            "file": {
                "data": "",
                "media": {
                    "name": "",
                    "storageArea": "SERIALIZED",
                    "binaryEncoding": "Base64",
                    "mime": "application/pdf"
                }
            },
            "coordinates": {
                "coordinates": {
                    "latitude": 45.456,
                    "longitude": -41.283
                },
                "type": "Point"
            }
        }
}

And there is in the Platform a subscription associated with this ontology and configured as:

  • queryField: $.Ticket.status
  • queryOperator: ‘=
  • projection: $.Ticket.file

A Java client subscribes to that subscription with the parameter queryValue = “DONE”

What will happen when new data is inserted in the Ticket ontology?

The answer is very simple: The system will evaluate whether the inserted data complies with the subscription and whethere there is any client to notify. Therefore, in this case, it will be verified that the status field of the inserted data indeed equals the value with which our Java client has subscribed, «DONE».

Please bear in mind that, for this check, we are using both the subscription configuration in the Platform (with the queryField and queryOperator properties) and the parameter that the client has used to subscribe (queryValue)

Once the condition has been verified as met, the Platform will notify the data to the Java client, but what data will be notified?

That’s it: It will notify whatever is defined with the “projection” property of the subscription, in this case:

"file": {
         "data": "",
         "media": {
             "name": "",
             "storageArea": "SERIALIZED",
             "binaryEncoding": "Base64",
             "mime": "application/pdf"
         }
}

Remember that this is a very simple example of how the new Platform subscription functionality works, so if you are interested in learning more about this tool, we recommend our help guide.

Any questions or problems you may have, please leave us a comment and we will analyze it as soon as possible.

✍🏻 Author(s)

Leave a Reply

Your email address will not be published. Required fields are marked *