{"id":13811454,"url":"https://github.com/apache/pulsar-client-node","last_synced_at":"2025-04-13T22:28:44.452Z","repository":{"id":37270228,"uuid":"173299242","full_name":"apache/pulsar-client-node","owner":"apache","description":"Apache Pulsar NodeJS Client","archived":false,"fork":false,"pushed_at":"2025-03-12T08:16:13.000Z","size":2023,"stargazers_count":154,"open_issues_count":70,"forks_count":89,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-04-06T19:08:26.791Z","etag":null,"topics":["event-streaming","javascript","messaging","node","nodejs","pubsub","pulsar","queuing","streaming"],"latest_commit_sha":null,"homepage":"https://pulsar.apache.org/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apache.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-01T12:35:51.000Z","updated_at":"2025-03-24T01:17:30.000Z","dependencies_parsed_at":"2022-07-14T04:00:36.143Z","dependency_job_id":"42e1a17f-3212-4dba-a1fa-fe73dea4daac","html_url":"https://github.com/apache/pulsar-client-node","commit_stats":{"total_commits":220,"total_committers":41,"mean_commits":5.365853658536586,"dds":0.8,"last_synced_commit":"1ad9d712aa89a5cd37cf0868cb6baa63c9445463"},"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fpulsar-client-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fpulsar-client-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fpulsar-client-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fpulsar-client-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/pulsar-client-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248520657,"owners_count":21117905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-streaming","javascript","messaging","node","nodejs","pubsub","pulsar","queuing","streaming"],"created_at":"2024-08-04T04:00:21.528Z","updated_at":"2025-04-13T22:28:44.417Z","avatar_url":"https://github.com/apache.png","language":"C++","readme":"\u003c!--\n\n    Licensed to the Apache Software Foundation (ASF) under one\n    or more contributor license agreements.  See the NOTICE file\n    distributed with this work for additional information\n    regarding copyright ownership.  The ASF licenses this file\n    to you under the Apache License, Version 2.0 (the\n    \"License\"); you may not use this file except in compliance\n    with the License.  You may obtain a copy of the License at\n\n      http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing,\n    software distributed under the License is distributed on an\n    \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n    KIND, either express or implied.  See the License for the\n    specific language governing permissions and limitations\n    under the License.\n\n--\u003e\n\n# Pulsar Node.js client library\n\nThe Pulsar Node.js client can be used to create Pulsar producers and consumers in Node.js. For the supported Pulsar features, see [Client Feature Matrix](https://pulsar.apache.org/client-feature-matrix/).\n\nThis library works only in Node.js 12.3 or later because it uses:\n1. The [node-addon-api](https://github.com/nodejs/node-addon-api) module to wrap the C++ library.\n2. The [Mozilla CA](https://nodejs.org/api/tls.html#tlsrootcertificates) file, which is provided by Node.js v12.3.0 and subsequent versions.\n\n## Getting Started\n\n\u003e **Note**\n\u003e\n\u003e These instructions are only available for versions after 1.8.0. For versions previous to 1.8.0, you need to install the C++ client first. Please switch to the corresponding version branch of this repo to read the specific instructions.\n\u003e\n\u003e To run the examples, skip this section.\n\nTo use the Pulsar Node.js client in your project, run:\n\n```shell\nnpm install pulsar-client\n```\n\nor\n\n```shell\nyarn add pulsar-client\n```\n\nThen you can run the following simple end-to-end example:\n\n```javascript\nconst Pulsar = require('pulsar-client');\n\n(async () =\u003e {\n  // Create a client\n  const client = new Pulsar.Client({\n    serviceUrl: 'pulsar://localhost:6650'\n  });\n\n  // Create a producer\n  const producer = await client.createProducer({\n    topic: 'persistent://public/default/my-topic',\n  });\n\n  // Create a consumer\n  const consumer = await client.subscribe({\n    topic: 'persistent://public/default/my-topic',\n    subscription: 'sub1'\n  });\n\n  // Send a message\n  producer.send({\n    data: Buffer.from(\"hello\")\n  });\n\n  // Receive the message\n  const msg = await consumer.receive();\n  console.log(msg.getData().toString());\n  consumer.acknowledge(msg);\n\n  await producer.close();\n  await consumer.close();\n  await client.close();\n})();\n```\n\nYou should find the output as:\n\n```\nhello\n```\n\nYou can see more examples in the [examples](./examples) directory. However, since these examples might use an API that was not released yet, you need to build this module. See the next section.\n\n## How to build\n\n\u003e **Note**\n\u003e\n\u003e Building from source code requires a Node.js version greater than 16.18.\n\nFirst, clone the repository.\n\n```shell\ngit clone https://github.com/apache/pulsar-client-node.git\ncd pulsar-client-node\n```\n\nSince this client is a [C++ addon](https://nodejs.org/api/addons.html#c-addons) that depends on the [Pulsar C++ client](https://github.com/apache/pulsar-client-cpp), you need to install the C++ client first. You need to ensure there is a C++ compiler that supports C++11 installed in your system.\n\n- Install C++ client on Linux:\n\n```shell\npkg/linux/download-cpp-client.sh\n```\n\n- Install C++ client on Windows:\n\n```shell\npkg\\windows\\download-cpp-client.bat\n```\n\n- Install C++ client on macOS:\n\n```shell\npkg/mac/download-cpp-client.sh\n```\n\nAfter the C++ client is installed, run the following command to build this C++ addon.\n\n```shell\nnpm install\n```\n\nTo verify it has been installed successfully, you can run an example like:\n\n\u003e **Note**\n\u003e\n\u003e A running Pulsar server is required. The example uses `pulsar://localhost:6650` to connect to the server.\n\n```shell\nnode examples/producer\n```\n\nYou should find the output as:\n\n```\nSent message: my-message-0\nSent message: my-message-1\nSent message: my-message-2\nSent message: my-message-3\nSent message: my-message-4\nSent message: my-message-5\nSent message: my-message-6\nSent message: my-message-7\nSent message: my-message-8\nSent message: my-message-9\n```\n\n## Documentation\n\nFor more details about Pulsar Node.js clients, see [Pulsar docs](https://pulsar.apache.org/docs/client-libraries-node/).\n\n### Contribute\n\nContributions are welcomed and greatly appreciated.\n\nIf your contribution adds Pulsar features for Node.js clients, you need to update both the [Pulsar docs](https://pulsar.apache.org/docs/client-libraries/) and the [Client Feature Matrix](https://pulsar.apache.org/client-feature-matrix/). See [Contribution Guide](https://pulsar.apache.org/contribute/site-intro/#pages) for more details.\n\n### Generate API docs\n\n```shell\nnpm install\nnpx typedoc\n# Documentation generated at ./apidocs\n```\n","funding_links":[],"categories":["Clients"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fpulsar-client-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fpulsar-client-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fpulsar-client-node/lists"}