Getting Started with binaries

Published: February 22, 2022

This guide is for getting started using the Pulsar binaries. Lets do this!

Steps

Get the Pulsar binaries

Pulsar is developed for 64-bit Java. To run the binaries you need either the Java Runtime Environment(JRE) or Java Developer Kit(JDK) version 8 or later installed. Installers and more info available here.

With a Java environment in place, all popular 64-bit desktops are supported - Windows, Linux, and MacOS. The tarball is around 300mb, so please be patient while downloading.

Start the Pulsar broker

Pulsar has quite a few supporting services (Bookkeeper, Zookeeper, etc). Within the main binary there is a standalone command that will run everything needed. Learn more about the command here.

1
2
3
4
5
# This will run the broker in the background (where you can't see logs)
./bin/pulsar-daemon start standalone

# Switch to this, in a new terminal, to run the Broker in the current thread
#./bin/pulsar standalone

Send a message to the Broker

Otherwise known as producing a message. Pulsar will create a new topic (if it doesn’t already exist) named “my-first-topic”.

1
./bin/pulsar-client --url "pulsar://localhost:6650/default/public/" produce "my-first-topic" --messages "Hello there"

There will be quite a bit of feedback output to the screen. Upon a successful publish, the last line should be…

[main] INFO org.apache.pulsar.client.cli.PulsarClientTool - 1 messages successfully produced

Get messages from the Broker

Otherwise known as consuming messages. Similar to producing, if the topic does not exists Pulsar will create it.

1
./bin/pulsar-client --url "pulsar://localhost:6650/default/public/" consume "my-first-topic" -s "my-subscription"

There will be quite a bit of feedback output to the screen. Upon a successful connection, the last line should be…

[main] INFO org.apache.pulsar.client.cli.PulsarClientTool - 1 messages successfully consumed

Stop the Broker

If you chose to run the Broker in the current thread Ctrl+c will stop the process. To stop the background process:

1
./bin/pulsar-daemon stop standalone

Summary

It doesn’t get any easier than that! You’ve successfully started a Pulsar instance, produced messages, and consumed messages. Let’s move on to something a little more challenging.

Troubleshooting

Error: JAVA_HOME not set, and no java executable found in…

The JAVA_HOME environment variable is a way of interacting with the runtime. Usually when this value is not set, that indicates there is no Java environment installed. Refer to the prerequisites.

Popup window: How do you want to open this file?

This is a popup that appears in Windows when you try to execute an unknown type of binary. Refer to the prerequisites to install the Java environment.