Apache Pulsar Go Client Library - httpspulsar.apache.org

Clone this repo:


  1. 4d788d9 [Issue #153] Fix handler memory leak (#154) by Rui Fu · 6 days ago master
  2. 6a08460 Fix partition key not set in batch builder (#175) by 冉小龙 · 6 days ago
  3. e78a368 [Issue:173] Fix logrus crash (#174) by 冉小龙 · 7 days ago
  4. 9b739cf Enable Github Action CI (#170) by 冉小龙 · 9 days ago
  5. ba9ec93 Create go.yml by 冉小龙 · 10 days ago

GoDoc Go Report Card Language LICENSE

Apache Pulsar Go Client Library

A Go client library for the Apache Pulsar project.


This projects is developing a pure-Go client library for Pulsar that does not depend on the C++ Pulsar library.

Once feature parity and stability are reached, this will supersede the current CGo based library.


  • Go 1.11+


Check the Projects page at https://github.com/apache/pulsar-client-go/projects for tracking the status and the progress.


Import the client library:

import "github.com/apache/pulsar-client-go/pulsar"

Create a Producer:

client, err := pulsar.NewClient(pulsar.ClientOptions{
    URL: "pulsar://localhost:6650",

defer client.Close()

producer, err := client.CreateProducer(pulsar.ProducerOptions{
	Topic: "my-topic",

_, err = producer.Send(context.Background(), &pulsar.ProducerMessage{
	Payload: []byte("hello"),

defer producer.Close()

if err != nil {
    fmt.Println("Failed to publish message", err)
fmt.Println("Published message")

Create a Consumer:

client, err := pulsar.NewClient(pulsar.ClientOptions{
    URL: "pulsar://localhost:6650",

defer client.Close()

consumer, err := client.Subscribe(pulsar.ConsumerOptions{
        Topic:            "my-topic",
        SubscriptionName: "my-sub",
        Type:             pulsar.Shared,

defer consumer.Close()

msg, err := consumer.Receive(context.Background())
    if err != nil {

fmt.Printf("Received message msgId: %#v -- content: '%s'\n",
            msg.ID(), string(msg.Payload()))


Contributions are welcomed and greatly appreciated. See CONTRIBUTING.md for details on submitting patches and the contribution workflow.


Mailing lists
users@pulsar.apache.orgUser-related discussionsSubscribeUnsubscribeArchives
dev@pulsar.apache.orgDevelopment-related discussionsSubscribeUnsubscribeArchives

Pulsar slack channel #dev-go at https://apache-pulsar.slack.com/

You can self-register at https://apache-pulsar.herokuapp.com/


Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0