experiment-pulsar-request-reply

A learning project experimenting with request-reply semantics on Pulsar. Inspired by NATS.

     1 |     ^
       v   6 |
---------------------           ---------------------
|  request service  |           |   reply service   |
---------------------           ---------------------
     2 |      ^                         ^   4 |
       v    5 |                       3 |     v
--------------------------------------------------------
|                  Pulsar message bus                  |
--------------------------------------------------------

Run it

Start Pulsar

docker run --rm -it \
  -p 6650:6650 \
  -p 8080:8080 \
  --name pulsar \
  apachepulsar/pulsar:2.6.0 \
  bin/pulsar standalone

Build the demo application

./gradlew build

Start the reply service

java -jar build/libs/demo-0.0.1-SNAPSHOT.jar --reply_service

Start the request service

java -jar build/libs/demo-0.0.1-SNAPSHOT.jar --request_service

Send some input to the request service on stdin and watch the replies come back.

For example

hello
REQUEST: hello
REPLY: HELLO!!!!!!!

Or pipe input into stdin

cat README.md | java -jar build/libs/demo-0.0.1-SNAPSHOT.jar --request_service

Misc notes

You can docker exec into the Pulsar container and use pulsar-client to debug and observe what's happening on Pulsar.

/pulsar/bin/pulsar-client produce non-persistent://public/default/topic -m somemessage 
/pulsar/bin/pulsar-client consume non-persistent://public/default/topic -s subscribername