Installations
npm install seneca-amqp-transport-fixed-versions
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
4.4.5
NPM Version
2.15.5
Score
67.6
Supply Chain
96
Quality
72.6
Maintenance
25
Vulnerability
97.6
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (97.59%)
Shell (2.41%)
validate.email 🚀
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Developer
senecajs
Download Statistics
Total Downloads
852
Last Day
1
Last Week
2
Last Month
13
Last Year
61
GitHub Statistics
MIT License
68 Stars
191 Commits
25 Forks
9 Watchers
158 Branches
9 Contributors
Updated on Dec 19, 2023
Bundle Size
337.28 kB
Minified
88.60 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.1.0
Package Id
seneca-amqp-transport-fixed-versions@2.1.0
Size
12.34 kB
NPM Version
2.15.5
Node Version
4.4.5
Total Downloads
Cumulative downloads
Total Downloads
852
Last Day
0%
1
Compared to previous day
Last Week
0%
2
Compared to previous week
Last Month
116.7%
13
Compared to previous month
Last Year
10.9%
61
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Note: This fork removes carets from package.json dependencies.
Official Seneca AMQP transport plugin
seneca-amqp-transport
This plugin allows seneca listeners and clients to communicate over AMQP.
Important notice: If you are upgrading to
2.1.0
from an older version, please read and follow instructions on this wiki guide to avoid some potential issues.
Install
1npm install --save seneca-amqp-transport
This transport supports AMQP 0-9-1, which is what amqplib currently supports. For an AMQP 1.0 compliant transport, take a look at seneca-servicebus-transport
Usage
The following snippets showcase the most basic usage examples.
Listener
1require('seneca')() 2 .use('seneca-amqp-transport') 3 .add('cmd:log,level:*', function(req, done) { 4 console[req.level](req.message); 5 return done(null, { ok: true, when: Date.now() }); 6 }) 7 .listen({ 8 type: 'amqp', 9 pin: 'cmd:log,level:*', 10 url: process.env.AMQP_URL 11 });
How it works
A listener always creates one and only one queue. The queue name can be provided via the name
parameter, but it will be auto-generated from the pin
(or pins
) if not.
Be careful with name clashing when specifying a
name
for a listener. Having more than one queue with the same name declared on the AMQP broker will probably behave unexpectedly. It is recommended that you leave the name generation to the plugin in order to avoid problems, unless you know what you are doing.
In the example above, the following things are declared:
- A topic exchange named
seneca.topic
. - A queue named
seneca.cmd:log.level:any
. - A binding between the queue and the exchange using the routing key
cmd.log.level.*
(named after the pin).
Queue names are prefixed with a configurable word (
seneca.
, by default). It can be disabled or modified during plugin declaration (read below).
If your intention is to create multiple queues, just declare multiple listeners. Each queue will be bound to an exchange (seneca.topic
, by default) using routing keys derived from the pin
(or pins
).
If your intention is to declare multiple consumers on a single queue, run multiple listeners with the same set of pins
. Or just spawn many instances of a single microservice.
Client
1var client = require('seneca')() 2 .use('seneca-amqp-transport') 3 .client({ 4 type: 'amqp', 5 pin: 'cmd:log,level:log', 6 url: process.env.AMQP_URL 7 }); 8 9setInterval(function() { 10 client.act('cmd:log,level:log', { 11 message: 'Hello World' 12 }, (err, res) => { 13 if (err) { 14 // Handle error in some way 15 throw err; 16 } 17 // Print out the response 18 console.log(res); 19 }); 20}, 2000); 21
How it works
A client creates an exclusive, randomly named response queue (something similar to seneca.act.x42jK0l
) and starts consuming from it - much like a listener would do. On every act
, the client publishes the message to the seneca.topic
exchange using a routing key built from the pin that matches the act pattern. In the simple example above, the pattern is cmd:log,level:log
which equals the only declared pin. With that, the routing key cmd.log.level.log
is inferred. An AMQP replyTo
header is set to the name of the random queue, in an RPC-schema fashion.
Manual queue naming on a client (using the
name
parameter as seen in the listener configuration) is not supported. Client queues are deleted once the client disconnect and re-created each time.
As you can see, pins play an important role on routing messages on the broker, so in order for a listener to receive messages from a client, their pins must match.
In the example, the following things are declared:
- A topic exchange named
seneca.topic
. - An exclusive queue with a random alphanumeric name (like
seneca.act.x42jK0l
).
Clients do not declare the queue of their listener counterpart. So, if the message does not reach its destination or is discarded by the broker, the
seneca
instance will fail with aTIMEOUT
error on the client side.
Options
The JSON object in defaults.json
describes the available options for this transport. These are applicable to both clients and listeners.
To override this settings, pass them to the plugin's .use
declaration:
1require('seneca')() 2 .use('seneca-amqp-transport', { 3 amqp: { 4 client: { 5 queues: { 6 options: { 7 durable: false 8 } 9 } 10 } 11 } 12 });
Transport options
AMQP related options may be indicated either by the connection URI or by passing additional parameters to the seneca#client()
or seneca#listen()
functions.
This,
1require('seneca')() 2 .use('seneca-amqp-transport') 3 .client({ 4 type: 'amqp', 5 url: 'amqp://guest:guest@rabbitmq.host:5672/seneca?locale=es_AR' 6 });
will result in the same connection URI as:
1require('seneca')() 2 .use('seneca-amqp-transport') 3 .client({ 4 type: 'amqp', 5 hostname: 'rabbitmq.host', 6 port: 5672, 7 vhost: 'seneca', 8 locale: 'es_AR', 9 username: 'guest', 10 password: 'guest' 11 });
Socket options
Additionally, you may pass in options to the amqp.connect
method of amqplib as documented in its API reference, using the socketOptions
parameter.
1// Example of using a TLS/SSL connection. Note that the server must be 2// configured to accept SSL connections; see http://www.rabbitmq.com/ssl.html. 3 4var fs = require('fs'); 5 6var opts = { 7 cert: fs.readFileSync('../etc/client/cert.pem'), 8 key: fs.readFileSync('../etc/client/key.pem'), 9 // cert and key or 10 // pfx: fs.readFileSync('../etc/client/keycert.p12'), 11 passphrase: 'MySecretPassword', 12 ca: [fs.readFileSync('../etc/testca/cacert.pem')] 13}; 14 15require('seneca')() 16 .use('seneca-amqp-transport') 17 .client({ 18 type: 'amqp', 19 url: 'amqp://guest:guest@rabbitmq.host:5672/seneca?locale=es_AR', 20 socketOptions: opts 21 });
Snippet above is based on amqplib/examples/ssl.js
Run the examples
There are simple examples under the /examples
directory. To run them, just install latest seneca
(if you didn't install devDependencies
) and execute:
1#Install seneca 2npm i seneca 3 4# Start listener.js 5cd examples 6AMQP_URL='amqp://guest:guest@dev.rabbitmq.com:5672' node listener.js 7{"kind":"notice","notice":"seneca started","level":"info","when":1476216405556} 8 9# Start client.js 10cd examples 11AMQP_URL='amqp://guest:guest@dev.rabbitmq.com:5672' node client.js 12{"kind":"notice","notice":"seneca started","level":"info","when":1476216473818} 13{ id: 93, 14 message: 'Hello World!', 15 from: { pid: 4150, file: 'examples/listener.js' }, 16 now: 1476306009801 } 17# ...
If you don't export the env variable
AMQP_URL
the default value ofamqp://localhost
will be used.
Contributors
- George Haidar (ghaidar0@gmail.com) (author of the original version).
- Chris Spiliotopoulos (chrysanthos.spiliotopoulos@gmail.com)
Roadmap
- :muscle:
Mocha unit tests. - Functional tests.
- :muscle:
Setup Travis CI. - :muscle:
Support for message TTL and dead-lettering(#59). - Better support for work queues.
- Better support for fanout exchanges.
- Don't depend on pins for routing (#58).
Contributing
This module follows the general Senecajs.org contribution guidelines and encourages open participation. If you feel you can help in any way, or discover any issues, feel free to create an Issue or a Pull Request. For more information on contribution please see our Contributing guidelines.
License
Licensed under the MIT license.

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/19 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 14 are checked with a SAST tool
Reason
50 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6
- Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9
- Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f
- Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p
- Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv
- Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8
- Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65
- Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546
- Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx
- Warn: Project is vulnerable to: GHSA-675m-85rw-j3w4
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg
- Warn: Project is vulnerable to: GHSA-gqgv-6jq5-jjj9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-2xwv-3cc9-fp7c
- Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp
- Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
- Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm
Score
2
/10
Last Scanned on 2025-03-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More