如果没有安装 Docker,可以下载,并按照相应操作系统的说明进行操作。

  • MacOS、Linux、Windows 用户:

A few things to note about this command:

  • The data, metadata, and configuration are persisted on Docker volumes in order to not start “fresh” every time the container is restarted. For details on the volumes you can use
  • For Docker on Windows make sure to configure it to use Linux containers
  1. 2017-08-09 22:34:04,038 - INFO - [main:PulsarService@335] - messaging service is ready, bootstrap service on port=8080, broker url=pulsar://127.0.0.1:6650, cluster=standalone, configs=org.apache.pulsar.broker.ServiceConfiguration@4db60246
  2. ...

Pulsar 支持多个客户端: Java、、Python 和 。 如果运行的是本地独立集群,则可以使用以下 URL 中的一个与其交互:

  • pulsar://localhost:6650

以下示例展示了如何通过 Python 客户端的 API 快速入门 Pulsar。

创建 consumer 并订阅 topic:

  1. import pulsar
  2. client = pulsar.Client('pulsar://localhost:6650')
  3. consumer = client.subscribe('my-topic',
  4. msg = consumer.receive()
  5. print("Received message: '%s'" % msg.data())
  6. consumer.acknowledge(msg)
  7. client.close()

Produce 一条消息

启动 producer,发送测试消息:

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.

  1. $ curl http://localhost:8080/admin/v2/persistent/public/default/my-topic/stats | python -m json.tool

输出应如下所示: