Use the Astra Streaming Pulsar Client
You can use the pulsar-client
CLI to produce and consume messages in your Astra Streaming tenants.
-
Set the following environment variables:
TOPIC="my-topic" NAMESPACE="my-namespace" TENANT="my-stream-RANDOM_UUID"
Replace RANDOM_UUID with any random letters and numbers to create a unique tenant name.
-
Produce a message:
# Produce a new message on the given tenant/namespace/topic ./bin/pulsar-client produce \ "$TENANT/$NAMESPACE/$TOPIC" \ --messages "Hi there" \ --num-produce 1
Your topic now has a new, unacknowledged message.
-
Create a consumer to retrieve and acknowledge the 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
-
Make sure the output includes your message:
# consumer message output ----- got message ----- key:[null], properties:[], content:Hi there 2023-01-09T14:32:40,502-0500 [pulsar-client-io-1-1] INFO org.apache.pulsar.client.impl.ConsumerImpl - [new-tenant-from-cli/default/demo] [examples-subscriber] Closed consumer 2023-01-09T14:32:40,504-0500 [main] INFO org.apache.pulsar.client.impl.PulsarClientImpl - Client closing. URL: pulsar+ssl://pulsar-aws-useast2.streaming.datastax.com:6651 2023-01-09T14:32:40,514-0500 [pulsar-client-io-1-1] INFO org.apache.pulsar.client.impl.ClientCnx - [id: 0x08d05240, L:/192.168.50.167:52883 ! R:pulsar-aws-useast2.streaming.datastax.com/3.138.177.230:6651] Disconnected 2023-01-09T14:32:40,520-0500 [pulsar-client-io-1-1] INFO org.apache.pulsar.client.impl.ClientCnx - [id: 0x934157ae, L:/192.168.50.167:52884 ! R:pulsar-aws-useast2.streaming.datastax.com/3.138.177.230:6651] Disconnected 2023-01-09T14:32:42,613-0500 [main] INFO org.apache.pulsar.client.cli.PulsarClientTool - 1 messages successfully consumed