Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
rabbitmq-pub-sub
Advanced tools
TypeScript NodeJs Platform
A typescript library for producing and consuming rabbitmq messages
If you don't have typings
installed:
npm i typings -g
Install via npm
npm i rabbitmq-pub-sub --save
You will also need these ambient dependencies:
NOTE: you might already have some of these ambient dependencies installed!
typings install amqplib bluebird bunyan node -SA
import {RabbitMqConnectionFactory,RabbitMqConsumer,RabbitMqProducer,IRabbitMqConnectionConfig} from "rabbitmq-pub-sub";
import * as Logger from "bunyan"
const logger: Logger = //create logger
interface IMessage{
data: string;
value: number;
}
// Create connection with amqp connection string
// const factory = new RabbitMqConnectionFactory(logger, "amqp://localhost:1234");
// or, create connection with host/port config
const config:IRabbitMqConnectionConfig = {
host:"localhost",
port:1234
}
const factory = new RabbitMqConnectionFactory(logger, config);
const consumer = new RabbitMqConsumer(logger, factory)
consumer.subscribe<IMessage>("<queue name>", m => {
// message received
console.log("Message", m.data, m.value)
}).then(disposer => {
// later, if you want to dispose the subscription
disposer().then(() => {
// resolved when consumer subscription disposed
});
}).catch(err => {
// failed to create consumer subscription!
});
const producer = new RabbitMqProducer(logger, factory)
producer.publish<IMessage>("<queue name>", {data: "data", value: 23})
.then(() => {
// sent to queue
}).catch((err) => {
// failed to enqueue
})
amqp library
Rokot - Rocketmakers
FAQs
RabbitMq Producer and Consumer
The npm package rabbitmq-pub-sub receives a total of 387 weekly downloads. As such, rabbitmq-pub-sub popularity was classified as not popular.
We found that rabbitmq-pub-sub demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.