Simple Apache Pulsar Local Setup

Apache Pulsar is an open-source distributed pub-sub messaging system. While it was originally created by Yahoo, Pulsar is now a part of the Apache Software Foundation.

2 months ago

Latest Post Cloud Development Kit for Kubernetes (cdk8s) by Tyler Moon

Apache Pulsar is an open-source distributed pub-sub messaging system. While it was originally created by Yahoo, Pulsar is now a part of the Apache Software Foundation.

In this article, we will look into a quick setup to get Pulsar up and running locally in a minimal fashion. In future articles, we will investigate the client libraries, Pulsar Functions, and running out of Docker containers.

Prerequisites

Install Standalone

To get started download the Pulsar binary tarball release:

wget https://archive.apache.org/dist/pulsar/pulsar-2.6.0/apache-pulsar-2.6.0-bin.tar.gz

Then unzip and navigate into the directory:

tar xvfz apache-pulsar-2.6.0-bin.tar.gz
cd apache-pulsar-2.6.0

Start local from command-line

To start a local cluster use the pulsar command in the bin directory:

bin/pulsar standalone

Now there is a standalone version of Pulsar running as long as that terminal is up. In order to run it in the background check the next section. If you do not want to worry about it running in the background skip to the "Consume a message"

Start local from daemon

To start a background daemon process run the pulsar-daemon command:

bin/pulsar-daemon start standalone

In order to stop the background process run:

bin/pulsar-daemon stop standalone

Consume a message

In a separate terminal run the following command to create a subscription on the my-topic topic:

bin/pulsar-client consume my-topic -s "first-subscription"

Produce a hello world message

To send a message to the consumer setup above start another terminal and execute the following pulsar-client command:

bin/pulsar-client produce my-topic --messages "hello world!"

On the terminal setup for the consumer something like the following should show up:

Example Hello World message consumed

Summary

In this short article, we saw how to set up the Apache Pulsar messaging system locally.

Tyler Moon

Published 2 months ago