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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ccloud-node-console-client

v0.2.1

Published

Example Node.JS producer/consumer for Confluent Cloud

Downloads

3

Readme

ccloud-node-console-client

Example console consumer and console producer using Node.JS and Confluent Cloud

Features

  • Up to date support for Confluent Cloud - Apache Kafka as a Service (see https://www.confluent.io/confluent-cloud/)
  • Up to date feature set from use of node-rdkafka node.js client (see https://github.com/Blizzard/node-rdkafka)
  • Tested on Ubuntu, CentOS, macOS, and Raspbian
  • Supports dynamic topic, key, value, and partition inputs
  • Supports 0.10 and 0.11 timestamps

Dependencies

Linux dependencies

  • openssl
  • libssl-dev
  • libsasl2-dev
  • libsasl2-modules
  • C++ toolchain

macOS dependencies

  • Apple Xcode command line tools (for the compiler)
  • openssl installed via Brew (needed for root certs file in /usr/local/etc/openssl/cert.pem)
  • Export CPPFLAGS=-I/usr/local/opt/openssl/include and LDFLAGS=-L/usr/local/opt/openssl/lib

Install

Install ccloud-node-console-client from npm on macOS

brew install openssl
export CPPFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib
sudo -E npm install -g ccloud-node-console-client

Install ccloud-node-console-client from npm on Ubuntu

sudo apt install nodejs-legacy
sudo apt install openssl libssl-dev libsasl2-dev libsasl2-modules
sudo npm install -g ccloud-node-console-client

Install ccloud-node-console-client from npm on CentOS

sudo yum install epel-release nodejs
sudo yum install openssl openssl-devel cyrus-sasl-devel
sudo npm install -g ccloud-node-console-client

Uninstall

sudo npm uninstall -g ccloud-node-console-client

Useage

ccloud-console-producer --help
Usage: ccloud-console-producer -e <endpoint> -k <apikey> -s <apisecret> -t <topic> -S <ssl ca location> -v

Options:
  -e, --endpoint   Confluent Cloud Endpoints (Broker List)  [required]
  -k, --apikey     Confluent Cloud API Key                  [required]
  -s, --apisecret  Confluent Cloud API Secret               [required]
  -t, --topic      Kafka Topic to consume from              [required]
  -v, --verbose    Verbose mode                             [boolean]
  -S, --sslcaloc   SSL CA Location                          [default: "/usr/local/etc/openssl/cert.pem"]
  -?, --help       Print usage information

Missing required arguments: e, k, s, t


ccloud-console-consumer --help
Usage: ccloud-console-consumer -e <endpoint> -k <apikey> -s <apisecret> -t <topic> -c <consumer group id> -S <ssl ca location> -v -b

Options:
  -e, --endpoint   Confluent Cloud Endpoints (Broker List)       [required]
  -b, --beginning  Consume messages from beginning               [boolean]
  -k, --apikey     Confluent Cloud API Key                       [required]
  -s, --apisecret  Confluent Cloud API Secret                    [required]
  -t, --topic      Kafka Topic to consume from                   [required]
  -c, --cgid       Consumer group.id (defaults to autogenerated
  -v, --verbose    Verbose mode                                  [boolean]
  -S, --sslcaloc   SSL CA Location                               [default: "/usr/local/etc/openssl/cert.pem"]
  -?, --help       Print usage information

Missing required arguments: e, k, s, t

Example Consumer

$ ccloud-console-consumer -e $CCLOUD_BROKERS -k $CCLOUD_SASL_USERNAME -s $CCLOUD_SASL_PASSWORD -t mytopic -v
Using consumer group.id = node-console-consumer594945
Setting auto.offset.reset = largest
Created consumer subscription on topic = mytopic
Got a message on topic "mytopic"
{ value: <Buffer 22 62 61 72 22>,
  size: 5,
  key: 'foo',
  topic: 'mytopic',
  offset: 0,
  partition: 0 }
calling commit
<Control-C>
Caught interrupt signal
consumer disconnected. {"connectionOpened":1498683661438}

Example Producer

$ ccloud-console-producer -e $CCLOUD_BROKERS -k $CCLOUD_SASL_USERNAME -s $CCLOUD_SASL_PASSWORD -t mytopic
Confluent Cloud connection is ready
prompt: key:  foo
prompt: value:  bar
Command-line input received:
  Message key: foo
  Message value: bar
Message published

Troubleshooting

If you see the following error when you run either console producer or consumer, it means you have not installed librdkafka correctly with the required SSL and SASL libraries. See install instructions for installing openssl and setting compiler flags.

Caught error: Error: Invalid value for configuration property "security.protocol"

If the ccloud-console-producer or ccloud-console-consumer immediately exits to the shell prompt you are likely missing the Root CA Certificates. See the location of these certs (below) and add the correct -S flag pointing the the location of the certs on your operating system.

The default SSL Certificate location is /usr/local/etc/openssl/cert.pem which works on macOS but every flavor of Linux puts root certificates in different places.

Ubuntu/Debian/Raspbian: /etc/ssl/certs
CentOS/RedHat: /etc/pki/tls/cert.pem
macOS: /usr/local/etc/openssl/cert.pem (from `brew install openssl`)

For Ubuntu add the -S /etc/ssl/certs flag to specify your certificate location:

ccloud-console-producer -e $CCLOUD_BROKERS -k $CCLOUD_SASL_USERNAME -s $CCLOUD_SASL_PASSWORD -t mytopic -v -S /etc/ssl/certs

For CentOS/RedHat add the -S /etc/pki/tls/cert.pem flag to specify your certificate location:

ccloud-console-producer -e $CCLOUD_BROKERS -k $CCLOUD_SASL_USERNAME -s $CCLOUD_SASL_PASSWORD -t mytopic -v -S /etc/pki/tls/cert.pem