Install Kafka With Docker



For local development and testing, you can run Pulsar in standalonemode on your own machine within a Docker container.

If you have not installed Docker, download the Community editionand follow the instructions for your OS.

Docker container run -p 8080:8080 -d employee-producer Now go to localhost:8080 So we have linked the docker internal port 8080 to our external port 8080. Now go to localhost:8080 and we can see that tomcat has started successfully. Next we will see how to go inside the docker and investigate it using the docker exec command. Kafka is recommended for production deployments. This queue is used on the most of ThingsBoard production environments now. It is useful for both on-prem and private cloud deployments. It is also useful if you like to stay independent from your cloud provider. However, some providers also have managed services for Kafka. See AWS MSK for example.

Start Pulsar in Docker

A few things to note about this command:

Install Kafka With Docker Linux

  • The data, metadata, and configuration are persisted on Docker volumes in order to not start 'fresh' everytime the container is restarted. For details on the volumes you can use docker volume inspect <sourcename>
  • For Docker on Windows make sure to configure it to use Linux containers

If you start Pulsar successfully, you will see INFO-level log messages like this:

Tip

Install

When you start a local standalone cluster, a public/defaultnamespace is created automatically. The namespace is used for development purposes. All Pulsar topics are managed within namespaces.For more information, see Topics.

Use Pulsar in Docker

Pulsar offers client libraries for Java, Go, Pythonand C++. If you're running a local standalone cluster, you canuse one of these root URLs to interact with your cluster:

  • pulsar://localhost:6650
  • http://localhost:8080

The following example will guide you get started with Pulsar quickly by using the Pythonclient API.

Install Kafka With Docker Download

Install the Pulsar Python client library directly from PyPI:

Consume a message

Install Kafka With Docker Container

Create a consumer and subscribe to the topic:

Produce a message

Now start a producer to send some test messages:

Install kafka docker compose

Get the topic statistics

Install Kafka With Docker Cli

In Pulsar, you can use REST, Java, or command-line tools to control every aspect of the system.For details on APIs, refer to Admin API Overview.

Install Kafka With Docker Server

In the simplest example, you can use curl to probe the stats for a particular topic:

Install Kafka With Docker Centos

The output is something like this: