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.
- 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
- Check the container id of the pulsar
docker ps -a
- Execute into the container bash
docker exec -it <container-id> bash
- Get the cluster list
bin/pulsar-admin clusters list
- Get the tenant list
bin/pulsar-admin tenants list
- Get the namespaces list
bin/pulsar-admin namespaces list <tenant-name>
- Get the topics
bin/pulsar-admin topics list <tenant-name>/<namespace-name>
- Create a topic
bin/pulsar-admin topics create-partitioned-topic persistent://public/default/test-topic -p 1
- To produce a message to the topic
bin/pulsar-client produce persistent://public/default/test-topic --num-produce 1 --messages "Hello pulsar 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
NOTE: All the above commands assume, you are working on default tenants and default namespaces.
Top comments (0)