Skip to content

Latest commit

 

History

History

pulsar

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Pulsar

In this recipe we'll learn how to ingest data from Apache Pulsar.

This is the code for the following recipe: https://dev.startree.ai/docs/pinot/recipes/pulsar


Makefile

make recipe

To produce data into Pulsar, use the Python code below.

import pulsar
import json
import time
import random
import uuid

client = pulsar.Client('pulsar://localhost:6650')
producer = client.create_producer('events')

  message = {
    "ts": int(time.time() * 1000.0),
    "uuid": str(uuid.uuid4()).replace("-", ""),
    "count": random.randint(0, 1000)
}
payload = json.dumps(message, ensure_ascii=False).encode('utf-8')
producer.send(payload)
client.close()