This is based on https://gist.github.com/jiazhai/1cd48ab6c8f6c3012c895df9746799b5
1, build it from source code:
mvn install -DskipTests -Pdocker
2, or use docker pull
docker pull apachepulsar/pulsar-test-latest-version
docker-compose up
- use get network alis for your docker instances:
docker network ls
- start a client, and config the broker address: a. start a docker instance
docker run --name client-beijing -it --rm --network geodemo_pulsar apachepulsar/pulsar-test-latest-version:latest /bin/bash
b. in this docker instance run this command to replace the broker address in client.conf
$ sed -i "s/localhost/broker-beijing/g" conf/client.conf
c. do the same a.b.steps for shanghai, and guangzhou cluster:
docker run --name client-shanghai -it --rm --network geodemo_pulsar apachepulsar/pulsar-test-latest-version:latest /bin/bash
sed -i "s/localhost/broker-shanghai/g" conf/client.conf
docker run --name client-guangzhou -it --rm --network geodemo_pulsar apachepulsar/pulsar-test-latest-version:latest /bin/bash
sed -i "s/localhost/broker-guangzhou/g" conf/client.conf
choose 1 instance from above client-beijing / client-shanghai / client-guangzhou to create tenants an namespace.
bin/pulsar-admin tenants create my-tenant --allowed-clusters beijing,shanghai,guangzhou
bin/pulsar-admin namespaces create my-tenant/my-namespace --clusters beijing,shanghai,guangzhou
a. in both client-shanghai and client-guangzhou, create a subscription for the test topic, they will wait receive messages from client-beijing in client-shanghai
bin/pulsar-client consume -s "sub-shanghai" my-tenant/my-namespace/t1 -n 0
in client-guangzhou
bin/pulsar-client consume -s "sub-guangzhou" my-tenant/my-namespace/t1 -n 0
b. in client-beijing, produce message to the topic
bin/pulsar-client produce my-tenant/my-namespace/t1 --messages "hello-from-beijing-1" -n 10