Overview
This blog describes how eventing can be used in a non-enterprise application. Here we build a game application. It's a racing kind of game, where the admin will host the game, and other players will join and play it.
In every click of each player, the event is sent to the queue of
SAP Event Mesh. At the end of the game, we calculate the result by consuming all the
SAP Event Mesh messages through
AMQP.
After calculating the result, we can post it to Twitter via
SAP Open Connectors.
In the below image, you can see how the game looks like:
Use Case:
This Application is developed using Node.js and runs on the SAP Business Technology Platform (SAP BTP). It consumes services in SAP BTP like
SAP Event Mesh and
SAP Open Connectors. The events generated in the gaming backend are inserted into a queue in the Event Mesh service. The Application consumes these events to calculate the game result, and the serverless function publishes the result on Twitter via the
SAP Open Connectors.
Prerequisites
- A provisioned SAP BTP, Kyma runtime. Read this blog to get started.
- Quota available for the SAP Enterprise Messaging service, open connectors, and SAP HANA hdi-shared on the SAP BTP subaccount on which SAP BTP, Kyma runtime is enabled.
Game flow
- In initial stage we decide our game scenario and based on that write an API to create queue in SAP Event Mesh, In the below diagram at the time of room creation we are creating the queue.
*If you want to explore more APIs for messaging , you can refer to this
Link.
2. After writing the API to create a queue, we make some logic to send the events to that queue.
3. Consume all the events with the help of
AMQP.
4. Create serverless function to share the events data on twitter via
SAP open connector.
Final Game
References:
The sample project can be accessed at SAP-Samples Github
https://github.com/SAP-samples/cloud-kyma-serverless-nodejs