Sending Messages to a Deployed Model
Once you have deployed your real-time digital twin model, you can start sending messages to it using the REST Messaging API. This API sends JSON-formatted messages that are automatically routed to the proper digital twin instance. (An instance will be created if it does not exist.) Refer to the topic REST API Reference for full details on using the REST API. This topic provides a simple example to help you get started.
To send a message to an instance, build a JSON message containing the property names in the incoming message and their associated values. These properties match the ones you defined for incoming messages in the real-time digital twin model, and they are included in the body of the HTTP request using JSON format.
Here is an example of a message:
[{
"Temperature": 77.0,
"Status": "Normal",
"RPM": 7600,
"FilterEnabled": true
}]
To send the message to an instance of a given model, send an HTTP POST request to the ScaleOut Digital Twins™ service using a URL of the form:
https://realtimetwinapi.scaleoutsoftware.com/api/v1/messages/{modelname}/{instanceid}?apikey={key}
You will need an API key, which can be obtained in the ScaleOut Digital Twins UI.
Note
You can use any tool to test sending JSON messages using HTTP (e.g., Postman or curl commands).
If you want to add a timestamp to your message, you can use the built-in message property OriginationTimestamp. In this example, the message will use the timestamp you provide in the message:
[{
"MyNumberProperty": 77.0,
"MyStringProperty": "Some text to send to the instance",
"MyOtherNumberProperty": 12,
"MyBooleanProperty": true,
"OriginationTimestamp" : "2021-03-22T18:21"
}]
If no timestamp is provided, the OriginationTimestamp property will use the time of reception instead.
The following example shows how to send a message containing two properties, Temp and Status, to the instance turbine1 of the WindTurbine model:
curl -X POST "https://realtimetwinapi.scaleoutsoftware.com/api/v1/Messages/windTurbine/turbine1?apiKey=1234567890ABCDEF" -H "Content-Type: application/json" -d "[{ 'Temp': 65, 'Status': 'Running' }]"