
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
amqp-message-bus
Advanced tools
Node.js message bus interface for AMQP servers, such as RabbitMQ.
$ npm install amqp-message-bus
Install amqp-message-bus
from npm.
$ npm install amqp-message-bus --save
Create new message bus.
const MessageBus = require('amqp-message-bus');
const bus = new MessageBus({
queue: 'tasks',
url: 'amqp://localhost',
encryptionKey: 'keep-it-safe'
});
Connect to AMQP server and subscribe for messages.
bus.connect()
.then(() => bus.subscribe((msg, props, done) => {
// process msg + props
console.log(`Received message ${props.messageId} with priority ${props.priority}, published on ${props.timestamp}`);
// call done when message is done processing to remove from rabbitmq
done();
}))
// call this when you want to unsubscribe...
.then((unsubscribe) => unsubscribe())
// always catch errors with promises :-)
.catch((err) => console.error(err));
The same looks much better using async/await.
await bus.connect();
const unsubscribe = await bus.subscribe((msg, props, done) => {
// process msg + props
console.log(`Received message ${props.messageId} with priority ${props.priority}, published on ${props.timestamp}`);
// call done when ready to remove message from rabbitmq
done();
});
// call this when you want to unsubscribe...
await unsubscribe();
Connect to AMQP server, publish message and immediately disconnect.
bus.connect()
.then(() => bus.publish({ foo: 1, bar: 2 }))
.catch((err) => console.error(err))
.finally(() => bus.disconnect);
Constructs new message bus with the supplied properties.
spec
(Object) message bus properties (required).
spec.url
(string) AMQP server URL (required).spec.queue
(string) the name of the queue to subscribe to (required).spec.encryptionKey
(string) encryption key to use with assymetric encryption (optional). Signifies no encryption if left unspecified.const bus = new MessageBus({
queue: 'tasks',
url: 'amqp://localhost',
encryptionKey: 'keep-it-safe'
});
Connects to AMQP server using the connection properties specified at construction time.
Returns a native Promise.
bus.connect()
.then(() => {
console.log('Connected to amqp server');
})
.catch((err) => {
console.error(err);
});
Disconnects from AMQP server.
Returns a native Promise.
bus.disconnect()
.then(() => {
console.log('Disconnected from amqp server');
})
.catch((err) => {
console.error(err);
});
Subscribes to the message bus for incoming messages.
listener
(Function<Object, Object, Function>) listener function (required).msg
(Object) message body (required).props
(Object) message meta-data (required).done
(Function) call done to signal message proccessing is done (required).Please visit http://www.squaremobius.net/amqp.node/channel_api.html#channel_assertQueue for further info on props
meta-data.
Returns a native Promise resolving to an unsubscribe()
method.
const listener = (msg, props, done) => {
// do something with msg and props
console.log(JSON.stringify(msg, null, 2));
// call done when you are done with msg to remove from queue
done();
};
bus.subscribe(listener)
.then((unsubscribe) => {
// unsubscribe when ready
unsubscribe();
})
.catch((err) => {
console.error(err);
});
const unsubscribe = await bus.subscribe((msg, props, done) => {
// do something with msg and props
console.log(JSON.stringify(msg, null, 2));
// call done when you are done with msg to remove from queue
done();
});
// unsubscribe when ready
await unsubscribe();
Publishes the supplied message to the AMQP server.
content
(*) message body (required); can be any JSON serializable value, e.g. Object, Array.props
(Object) message props (optional).
props.id
(string) message ID (optional; defaults to UUID v4
)props.priority
(integer) message priority, must be between 1 and 10 (optional; defaults to 1)props.timestamp
(number) message timestamp (optional; defaults to Date.now()
)props.type
(string) message type (optional)Returns a native Promise resolving to a boolean value.
bus.publish({ foo: 'bar' }, { type: 'nonsense', priority: 10 })
.catch((err) => {
console.error(err);
});
await bus.publish({ foo: 'bar' }, { type: 'nonsense', priority: 10 });
Source code contributions are most welcome. The following rules apply:
FAQs
Node.js message bus interface for AMQP servers, such as RabbitMQ.
The npm package amqp-message-bus receives a total of 0 weekly downloads. As such, amqp-message-bus popularity was classified as not popular.
We found that amqp-message-bus 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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.