There are multiple APIs to send and receive data with the Streamsheets. To do so, it is necessary to understand the architecture of our System. The architectural basis of the communication from and to the Streamsheets works through Streams. These consist out of three different entities:
Connector, Consumer and Producer
To have an overview over all your Streams navigate to the Administration menu located on the left side of your screen. There you will find the Streams menu.
A Connector bridges the gap between the Streamsheets software and the data provider. It enables a data stream over an API of your choice and works as the foundation of a Producer and Consumer.
A Consumer defines input data source parameter and is associated to an Inbox of a Streamsheet. It is always dependent on its affiliated Connector.
A Producer defines output parameter and is used within a function on the Streamsheet. As the Consumer, it is always dependent on its affiliated Connector.
In the following I will create a MQTT Connector, Consumer and Producer. If you don´t know what MQTT is have a look here.
To either subscribe or publish to a topic in the Streamsheets you will have to connect to the broker of your choice. You can host your own broker, use open accessible broker like the IOT Eclipse MQTT Broker, or connect to our local MQTT Broker. To do so navigate into the Administration Menu. From there, navigate to Connectors and create a new one by clicking the plus in the top right corner.
After choosing the right provider (MQTT) you now see the settings menu of your Connector. In our example we will connect to our local broker. This is why we do not need a URL, but insert “broker” in the URL field. Our (and usually most other) MQTT broker uses the port 1883. Authentication is not required, this is why we skip the “user name” and “password” field.
The base topic is the first hierarchy level. Insert a description of your choice. This will not seem very useful for now, but at some point a structured MQTT topic hierarchy will help you a lot.
When successfully connected to the broker, you can now create a Consumer to receive and a Producer to publish messages. Together with the base topic of the Connector they can be used to specify a topic hierarchy.
To create a new Consumer to further define input parameters, switch menu to the Consumers menu. Here again click on the plus in the top right corner and this time choose your just created Connector.
Now insert all the topics you want to subscribe to in the MQTT Topics field. Always remember that these topics are extending the base topic of your Connector. So the example topic “test” really is “cedalo/test”.
Hint: It would also possible to insert “test/topic1” with “topic1” being a subtopic of “test” to create another hierarchy level (“cedalo/test/topic1”).
It is now possible to assign the Consumer to any Streamsheet inbox. This inbox then will list all messages published to the connected topics.
The Producer is very similar to the Consumer. Again change to the right menu and add another Producer by clicking the plus icon and choosing a Connector. It is now possible to further define the topic hierarchy of this Producer. In order to stay more flexible, we can leave this field blank. Since the desired topic hierarchy can also be defined later in a function.
To create output data with the Producer, open up a Streamsheet, click on a cell and open the Function Wizard. Choose MQTT.PUBLISH and choose your Producer from the list.
You can use every Producer and Consumer in as many functions/inboxes as you want. So it is not necessary to define these every time.
Eventhough we only covered MQTT the architecture to use any other API stays the same. Work with a Connector to get the initial connection set up and define the details for input and ouput in the Consumer and Producer.