The topic-stream is a simple stream which enables writing messages over either AMQP or MQTT to a topic.

npm install topic-stream
27 downloads in the last month

topic-stream Build Status

The topic-stream is a writable stream which translates objects written to into JSON messages which it sends over an AMQP topic.



This is a simple example using event-stream to pipeline data entered via stdin, split it into lines and send it via topic stream to /events/input over AMQP.

"use strict";

var es = require('event-stream');
var amqplib = require('amqplib');
var topicStream = require('../index.js');
var log = require('debug')('read-stdin-topic-stream');

// exit once we have processed the data that was piped in.
process.stdin.on('close', process.exit);

log('Connection', 'open');

var open = amqplib.connect();

topicStream(open, {exchangeName: 'events/syslog'}, function (err, ts) {
  log('topicStream', 'open');
  es.pipeline(process.stdin, es.split(), ts);

Anything sent to stdin on the process will be split into lines and packaged into AMQP messages.


  • Add the option to just pass an AMQP URL.


Copyright (c) 2013 Mark Wolfe Licensed under the MIT license.

npm loves you