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

amqp-to-mongo

v1.0.0

Published

save RabbitMQ messages to MongoDB collection

Downloads

14

Readme

AMQP to MongoDB

amqp-to-mongo consumes AMQP messages from one or more queues, and saves them to a MongoDB collection.

Usage and Configuration

Queue names to consume are given on the command line.

amqp-to-mongo queue-name [queue-name...]

Other behaviour is affected via the following environment variables:

  • AMQPHOST: AMQP Server URL (default: amqp://guest:guest@localhost)
  • MONGODB: MongoDB Database URL (default: mongodb://localhost/amqp)
  • MONGOCOLLECTION: Database collection to save to (default: messages)
  • TRANSLATECONTENT: translate content field (default: true)
  • REQUEUEERRORS: MongoDB errors rejected w/ requeue option (default: false)

WARNING: If you set REQUEUEERRORS=true, the message could be redelivered, possibly resulting in a loop! Drink this option responsibly!

Data Structures

The data structures are saved as consumed by amqplib, with a little extra:

  • date: new Date instance at moment of consumption
  • queue: name of AMQP Queue on which message arrived
  • fields: non-empty (null/undefined) values from amqplib
  • properties: non-empty (null/undefined) values from amqplib
  • content: content from amqplib, possibly translated

The date is intended to allow you to set a TTL index, or just to keep track of when the message was consumed (although the ObjectId can do this, too).

The queue is added so you can remember where the object came from, although routing info is also included in the fields from amqplib.

Content Translation

Content translation of the content field occurs prior to saving unless TRANSLATECONTENT is turned off. When turned off, the messages are saved as binary types.

If the AMQP message properties content-type and/or content-encoding are specified, the content will be translated.

  • application/json is parsed into JSON object
  • text/* is read as a string
  • everything else is saved as a string, encoded in ascii, base64, or utf-8, depending on content-encoding and whether possible to convert to utf-8