Set up a standalone Pulsar in Docker
如果没有安装 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
2017-08-09 22:34:04,030 - INFO - [main:WebService@213] - Web Service started at http://127.0.0.1:8080
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
...
Pulsar 支持多个客户端:、Go、<a href =“ client-libraries-python.md“>Python 和 。 如果运行的是本地独立集群,则可以使用以下 URL 中的一个与其交互:
pulsar://localhost:6650
以下示例展示了如何通过 Python 客户端的 API 快速入门 Pulsar。
创建 consumer 并订阅 topic:
import pulsar
client = pulsar.Client('pulsar://localhost:6650')
subscription_name='my-sub')
msg = consumer.receive()
print("Received message: '%s'" % msg.data())
consumer.acknowledge(msg)
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.
输出应如下所示: