DEV Community

Rahul Lokurte
Rahul Lokurte

Posted on

2

Getting Started with Apache Pulsar

Prerequisite

To run apache pulsar, you need to have the Docker installed on the system. You can download docker from https://docs.docker.com/docker-for-windows/install/

Getting Started

Note: Apache pulsar has a cluster and within cluster, we have tenants. Within Tenants, we have namespaces.

  1. Start the pulsar instance in Docker
docker run -it -p 6650:6650 -p 8080:8080 --mount source=pulsardata,target=/pulsar/data --mount source=pulsarconf,target=/pulsar/conf apachepulsar/pulsar:2.6.0 bin/pulsar standalone
Enter fullscreen mode Exit fullscreen mode
  1. Check the container id of the pulsar
docker ps -a
Enter fullscreen mode Exit fullscreen mode
  1. Execute into the container bash
docker exec -it <container-id> bash
Enter fullscreen mode Exit fullscreen mode
  1. Get the cluster list
bin/pulsar-admin clusters list
Enter fullscreen mode Exit fullscreen mode
  1. Get the tenant list
bin/pulsar-admin tenants list
Enter fullscreen mode Exit fullscreen mode
  1. Get the namespaces list
bin/pulsar-admin namespaces list <tenant-name>
Enter fullscreen mode Exit fullscreen mode
  1. Get the topics
bin/pulsar-admin topics list <tenant-name>/<namespace-name>
Enter fullscreen mode Exit fullscreen mode
  1. Create a topic
bin/pulsar-admin topics create-partitioned-topic persistent://public/default/test-topic -p 1
Enter fullscreen mode Exit fullscreen mode
  1. To produce a message to the topic
bin/pulsar-client produce persistent://public/default/test-topic --num-produce 1 --messages "Hello pulsar 1"
Enter fullscreen mode Exit fullscreen mode
  1. To Consume a message from the topic
bin/pulsar-client consume persistent://public/default/test-topic --num-messages 0 --subscription-name test-topic-sub --subscription-type Exclusive
Enter fullscreen mode Exit fullscreen mode

NOTE: All the above commands assume, you are working on default tenants and default namespaces.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️