Difficulty: Beginner
Estimated Time: 20 minutes

In this IoT sensor-based scenario, you will:

  • Create a Pulsar producer in Python
  • Create a Pulsar consumer in Python
  • Create a Pulsar Function in Python and configure it in Pulsar
  • Start producing messages, which will be transformed and re-routed within Pulsar
  • Use the consumer to receive and view the resulting messages

Check out our datastax.com/dev site, where you can find many more resources to help you succeed with Apache Cassandra™.

In this scenario, you learned how to:

  • Create a Pulsar producer in Python
  • Create a Pulsar consumer in Python
  • Create a Pulsar Function in Python and configure it in Pulsar
  • Start producing messages, which will be transformed and re-routed within Pulsar
  • Use the consumer to receive and view the resulting messages

Transforming and routing messages in Apache Pulsar™ with Pulsar Functions

Step 1 of 8

Introduction

In this scenario, Apache Pulsar™ Producer and Consumer are created and run with Python; a Pulsar Function, also written in Python, is configured to take care of routing messages between the two.

You have an IoT network made of two "stations" which generate temperature and pressure readings each to a single "raw-data" topic. You want to collect all temperature readings to a dedicated topic and all pressure readings to another using a Pulsar function that will re-route the messages.

But beware! One station uses Celsius degrees for the temperature, the other uses Fahrenheit degrees. Your Pulsar function must convert all temperatures to Kelvin by checking the "station version" tag coming with the readings.

Scenario workflow

First initialize all the Terminals in this order to avoid a bug in Katacoda:

echo "Initialize Terminal"
echo "Initialize Temperature reading Terminal"
echo "Initialize Pressure reading Terminal"
echo "Initialize Sensor station 1 Terminal"
echo "Initialize Sensor station 2 Terminal"
Terminal
Temperature reading
Pressure reading
Sensor station 1
Sensor station 2