This recipe implements an event-driven application using pubsub pattern with Apache Pulsar, a high-performance event streaming platform.
Overview
This sample code is based on the original Kafka recipe. The program runs the processors for sending and receiving Kafka messages as goroutines.
Pulsar Setup
Run Apache Pulsar. Note this will run Pulsar-Manager - see next section for details. It can take 10-25 seconds for pulsar to start.
$ docker-compose up
Run the go program.
$ go run main.go
Terminate the programs.
$ # Press CTRL-C to terminate the go program
$ # Next shutdown pulsar
$ docker-compose down
Alternatively, you can run everything with just one command.
$ make
$ docker-compose down # Run this to remove the containers
Pulsar Manager Setup
Pulsar Manager is a visual dashboard, a nice-to-have to quick inspect what Pulsar is doing (it's not required to get the code running). There's a bit of extra setup that you need to do before you can start using the tool.
Run docker-compose.
$ docker-compose up
Generate an admin account to access the tool.
$ ./gen-admin.sh
Launch the web browser and go to http://localhost:9527. Use username admin and password password to log into the tool.
Add an environment by connecting to the Pulsar host. Use the following parameters when creating a new environment.