In the third episode of Axual Expresso, a series of short videos where we learn more about streaming and the Axual Platform, Elise learns how you can produce and consume data from your data streaming application and how easy it is to create a Data Streaming Application on the Axual Platform with a quick demo by Abhinav Sonkar.
Have you missed the first two videos?
This is the third video of the Expresso series.
Sign up here to receive the other two Episodes in your mailbox:
In this video:
These are the questions asked in the video:
1. How can you produce and consume data from your data streaming application?
Last time, we had this application created called Expresso Application. We also had configured the principles, which are the certificates, the authentications that the application will use to connect to the stream.
Now we will make a request to produce and consume from the stream. On the Application Details page, we click on the “Add Request” button and we decide what type of operation we want to do. Let’s try “Produce”. So we want to produce from this application to the stream which we created earlier, called Expresso shots.
We have the stream available in the Development Environment so we choose that. Let’s make the request. The Development Environment is set to be auto-approved so we get access automatically to the stream to produce. And you can see here in the diagram that we now have access to produce. Let’s also set up the consume app. Add request for Consumer in the same way which we used for the stream. And we have consumer access to the stream as well. This is how you can request access to produce and consume.
2. Now we have access to the producer and the consumer but how can you produce data to the stream?
Now it is time to code to create the application. In the demo, Abhinav shares an example of an application he wrote. Some of the important details are:
Firstly the Application ID, which is set to Expresso App, is what needs to be defined when creating the application.
Secondly, the endpoint. This is where we find the stream that we defined.
Access to a stream is only allowed with certificates so we need to point the relevant key stored information, which is available in the file location.
With the “Keystore” and “Truststore” set up then we set the name of the stream where we want to produce. So in this case, the “Expresso shots” name and then some more details on how the application is written down which you can find in the documentation as well.
Now, to produce some message it’s very important to understand that a message is made out of two things: a key and a value. The key itself is not that relevant to the payload. Right now we have set it to a static change and we have the value, which is the payload, which is the relevant data that we want to put in the stream.
To protect key and value we will just produce the message here and return this successful or error information.
Now your application can start and the way we set up the example application in the demo is that it will produce a message every second.
2. How can you consume data from a stream?
So setting this application to consume data is very similar to the set up for the consumer. The Application ID, EndPoint, Tenant, and Environment will be the same.
Once the application is done it will stop consuming. A consumer application, by nature is running fortnightly because a message can come on a stream at any point in time so it has to keep running which is why we have an infinite loop setup.
3. But you earlier showed us that you need access to an application, therefore is it possible to remove access?
The application that we started earlier is still running and we have the producer application access so we will remove access to this stream from the UI and see what happens to the application. To do this, simply hover over the application name and a trash icon will appear, clicking on that will remove access to the stream.
If we check the status of the application we will see how it gives error messages and it’s not producing anymore. This indicates that the application can now no longer produce and the effect is in real-time. And to get back to the original state we can make the request again.
So this is how you consume and produce data from a data streaming application in the Axual platform.