Pulsar client with Astra Streaming
This guide assumes you have completed the Astra Streaming quickstart and you have set up your Pulsar binaries to work with your tenant.
Now it’s time to produce and consume messages in your new streaming tenant.
Set the required variables. If you’ve just completed the quickstart, these values are already set.
TOPIC="my-topic" NAMESPACE="my-namespace" TENANT="my-stream-<rand>" #replace <rand> with a few alphanumeric characters
Run the following script to create 1 new message.
# Produce a new message on the given tenant/namespace/topic ./bin/pulsar-client produce \ "$TENANT/$NAMESPACE/$TOPIC" \ --messages "Hi there" \ --num-produce 1
Now you have a new, unacknowledged message in your topic.
Run the following script to create a consumer that retrieves and acknowledges that message.
# Consume a new message on the given tenant/namespace/topic ./bin/pulsar-client consume \ "$TENANT/$NAMESPACE/$TOPIC" \ --subscription-name "examples-subscriber" \ --num-messages 1
The output should look similar to this:
404: Not Found
If you made it here then your produce & consume journey was successful. Congrats🎉! Now it’s time to take your skills further 🚀🚀.