Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
amqp-as-promised
Advanced tools
Promise wrapper around node-amqp.
npm install amqp-as-promised
conf = require './myconf.json' # see example conf below
amqpc = (require 'amqp-as-promised') conf.amqp
amqp
host
, vhost
, login
, password
specifies how to connect.local
: means there will be no AMQP connection.conf-localhost.json
{
"amqp": {
"host": "192.168.0.10",
"vhost": "test",
"login": "test",
"password": "supersecret"
},
}
amqpc
to publishamqpc.exchange('myexchange').then (ex) ->
msg = {}
msg.domain = domain
ex.publish 'mytopic.foo', msg
amqpc
to bindThis is shorthand for binding and subscribing.
amqpc.bind 'myexchange', 'myqueue', 'mytopic.#', (msg, headers, del) ->
console.log 'received message', msg
To bind an anonymous queue.
amqpc.bind 'myexchange', '', 'mytopic.#', (msg, headers, del) ->
console.log 'received message', msg
Or even shorter
amqpc.bind 'myexchange', 'mytopic.#', (msg, headers, del) ->
console.log 'received message', msg
amqpc
to get an anomymous queueTo create an anomymous queue.
amqpc.queue().then (q) -> console.log 'my queue', q
amqpc
to to RPC-style callsTo send a message to a service that honors the replyTo/correlationId contract:
amqpc.rpc('myexchange', 'routing.key', msg, [headers]).then ([msg, headers]) ->
console.log 'received message', msg
graceful = (opts) ->
log.info 'Shutting down'
amqpc.shutdown().then ->
process.exit 0
process.on 'SIGINT', graceful
process.on 'SIGTERM', graceful
amqpc
objectamqpc.exchange(name, opts)
A promise for an exchange. If opts
is omitted declares an exchange in passive
mode.
amqpc.queue(qname, opts)
A promise for a queue. If qname
is omitted, ""
is used. If opts is
omitted a default durable:true
and autoDelete:(qname=='')
. See
queue.*
below.
amqpc.bind(exname, qname, topic, callback)
Shorthand for
exname
. Note that passive:true
so
exchange must be declared already.qname
. See amqpc.queue
for queue default
opts.topic
.callback
to queue.amqpc.shutdown()
Will unbind all queues and unsubscribe all callbacks then gracefully shut down the socket connection.
amqpc.local
Read only property that tells whether conf.local
was true.
queue.bind(ex, topic)
Binds the queue to the given exchange (object, not name). Will unbind if queue was already bound.
queue.unbind()
Unbinds the queue (if currently bound).
queue.subscribe(opts, callback)
Subscribes the callback to this queue. Will unsubscribe any previous
callback. If opts is omitted, defaults to ack: false, prefetchCount: 1
queue.unsubscribe()
Unsubscribes current callback (if any).
queue.shift([reject[, requeue]])
To be used with queue.subscribe({ack:true}, callback)
. reject
rejects the previous message and will requeue it if requeue
is true.
queue.name
Read only property with the queue name.
FAQs
A promise-based AMQP API build on node-amqp
The npm package amqp-as-promised receives a total of 24 weekly downloads. As such, amqp-as-promised popularity was classified as not popular.
We found that amqp-as-promised demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.