npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@pulsar-js/producer

v1.0.7

Published

Apache Pulsar message producer with pre-built binaries for Node.js

Downloads

42

Readme

@pulsar-js/producer

@pulsar-js/producer provides a simple way to send messages to Apache Pulsar topics from Node.js.

Isn't there already an official module for this?

Yes, but it's hard to install. The official pulsar node client is a wrapper around the Pulsar C++ library. Using this in Node.js means your system must have a compiler (used by node-gyp). This can be an unnecessary barrier in environments that can't have build extra tools installed.

How does @pulsar-js/producer simplify my life?

This module downloads a pre-built binary for you. As a result, the npm install process does not need a build step or a compiler.

The pre-built binary was designed specifically for producing messages (not consuming). It was designed specifically for this node module, but it is a standalone CLI app that could be used independently of this module if desired.

Installation

npm install @pulsar-js/producer -S

Usage

import publish from '@pulsar-js/producer'

await publish('pulsar://my_server:5678/persistent/namespace/topic', "message"/*, options*/)

The connection string accepts pulsar:// or pulsar+ssl:// protocols. The syntax is protocol://server:port/[non-]persistent/namespace/topic

Options

The optional third argument to publish(connectionString, message, options) controls the producer configuration, message metadata, and authentication. The object is case-insensitive for the keys shown below.

Producer configuration

  • timeout (number, default: 30) – Seconds to wait for the underlying CLI to complete.
  • name (string, default: manual-producer) – Pulsar producer name.
  • properties (object) – Key/value pairs forwarded as Pulsar producer properties.

Message metadata

  • key (string) – Message key.
  • orderingKey (string) – Ordering key for KeyShared subscriptions.
  • eventTime (number) – Milliseconds since epoch representing the event timestamp.
  • replicationClusters (string[]) – One or more cluster names to replicate the message to.
  • disableReplication (boolean) – Skip cross-cluster replication.
  • sequenceId (number) – Explicit sequence identifier.
  • deliverAfter (number) – Delay delivery by N milliseconds.
  • deliverAt (number) – Deliver at the exact millisecond timestamp provided.
  • properties (object) – Message-level properties; each key/value is forwarded with --property.

Authentication (options.authorization or options.auth)

Provide an object with a type field plus the fields required by that mechanism:

  • OIDC / JWT (type: 'oidc')
    • token (string) – Raw JWT or path to a file containing the token.
    • allowUnverified (boolean, default: false) – Ignore JWT verification failures.
  • mTLS (type: 'mtls')
    • certPath (string) – Path to client certificate.
    • keyPath (string) – Path to client private key.
    • caCert (string) – Path to CA certificate bundle.
  • OAuth2 Client Credentials (type: 'oauth2')
    • issuer (string) – OAuth2 issuer / token URL.
    • privateKey (string) – Path to the service account private key.
    • audience (string) – Audience claim for issued tokens.
    • clientId (string) – OAuth2 client identifier.
  • Basic auth (type: 'basic')
    • username (string)
    • password (string)
  • Athenz (type: 'athenz')
    • domain (string)
    • tenant (string)
    • service (string)
    • privateKey (string) – Path to the Athenz service key.
    • url (string) – Athenz ZTS endpoint.
    • proxy (string, optional) – Proxy URL.
    • keyId (string, optional) – Key identifier header value.
    • caCert (string, optional) – Path to CA certificate bundle.

Any remaining properties in options are treated as message metadata. Authorization objects are removed before sending, so nested message data will not leak into the CLI invocation.

Use Cases

This module is designed primarily for node apps/scripts that need to publish occassional messages.

A new connection is established for each message/batch sent (no connection pooling). Once the message(s) are sent, the connection is dropped. This is not ideal for platforms that send a constant stream of messages or need the absolute least possible latency. However; if you need to send <60 messages per minute, the latency is negligble (<1ms) and the connections are lightweight.

The underlying go binary is structured as a standalone CLI. You could use it to easily/manually send messages from the console.