
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
amqp-simple-pub-sub
Advanced tools
A Pub Sub system that uses AMQP Messaging to exchange data between services
A Pub Sub system that uses AMQP
messaging to exchange data between services.
You project needs to be using at least Node version 10, and ideally Node 18 (LTS) or later.
npm install amqp-simple-pub-sub
const { makePublisher } = require('amqp-simple-pub-sub')
const publisher = makePublisher({ exchange: 'testService' })
await publisher.start()
publisher.publish('test', 'Hello World')
const { makeSubscriber } = require('amqp-simple-pub-sub')
const subscriber = makeSubscriber({
exchange: 'testService',
queueName: 'testQueue',
routingKeys: ['test']
})
const handler = message => {
console.log('Message Received', message)
subscriber.ack(message)
}
subscriber.start(handler)
The full options object is as follows
{
type: 'topic', // the default
url: 'amqp://localhost', // the default
exchange: 'you must provide this', // it's the name of your service usually
onError: err => { // optional
console.error('A connection error happened', err) // or do something clever
},
onClose: () => { // optional
console.log('The connection has closed.') // or do something clever
},
...otherOptions // anything else you pass in gets passed directly to `amqp.connect`
}
The full options object is as follows
{
type: 'topic', // the default
url: 'amqp://localhost', // the default
exchange: 'you must provide this', // it's the name of your service usually
queueName: 'you must also provide this', // give your queue a name
routingKeys: ['an', 'array', 'of', 'routingKeys'], // optional. Uses [queueName] otherwise.
onError: err => { // optional
console.error('A connection error happened', err) // or do something clever
},
onClose: () => { // optional
console.log('The connection has closed.') // or do something clever
},
...otherOptions // anything else you pass in gets passed directly to `amqp.connect`
}
As outlined above both createPublisher
and createPublisher
also accept other options.
These are passed straight onto amqp.connect
under the hood. The options are:
clientProperties
: see connect.js
credentials
keepAlive
keepAliveDelay
noDelay
servername
timeout
See some examples in the tests, and also:
amqp-delegate
— A library that simplifies, to the point of triviality, use of AMQP based remote workers.ampq-event-tester
— A Dockerised and configurable utility to help integration-test your AMQP services.Branch | Tests | Code Coverage | Audit | Comments |
---|---|---|---|---|
develop | Work in progress | |||
main | Latest release |
nvm
to manage Node versions — brew install nvm
.)npm install
docker compose up -d
Runs Rabbit MQ.
npm test
— runs the unit tests (quick and does not need rabbitmq
running)npm run test:unit:cov
— runs the unit tests with code coverage (does not need rabbitmq
)npm run test:integration
— runs the integration tests (needs rabbitmq
)npm run lint
Please see the contributing notes.
FAQs
A Pub Sub system that uses AMQP Messaging to exchange data between services
We found that amqp-simple-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
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.