Use the Astra Streaming Pulsar Client

You can use the pulsar-client CLI to produce and consume messages in your Astra Streaming tenants.

  1. Create a Astra Streaming tenant.

  2. Configure Pulsar binaries for Astra Streaming.

  3. 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.

  4. 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.

  5. 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
  6. 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

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com