{"_id":"amqp-helper","_rev":"30-af1e80c10f523a325683538b4e943edc","name":"amqp-helper","time":{"modified":"2022-06-13T02:46:37.712Z","created":"2016-12-05T16:25:06.308Z","0.7.1":"2016-12-05T16:25:06.308Z","0.8.0":"2016-12-19T12:51:57.897Z","0.8.1":"2016-12-19T15:40:11.179Z","2.0.0":"2017-02-20T19:13:39.639Z","2.0.1":"2017-03-03T13:17:31.741Z","2.0.2":"2017-03-04T17:40:36.773Z","2.0.3":"2017-03-04T20:20:59.698Z","2.0.4":"2017-03-04T20:37:55.381Z","2.0.5":"2017-03-04T20:47:10.258Z","2.0.6":"2017-03-06T14:59:07.663Z","2.0.7":"2017-03-06T14:59:51.704Z","2.0.8":"2017-03-11T13:07:41.016Z","0.0.1-security":"2017-03-22T15:18:18.242Z","1.0.0":"2019-01-15T07:14:59.038Z"},"maintainers":[{"email":"ale.carbo@gmail.com","name":"a.carbone"}],"dist-tags":{"latest":"1.0.0"},"description":"A Node.js helper for AMQP messaging.","readme":"# amqp-helper\n\nA Node.js helper for AMQP messaging.\n\n## Installation\n\nStill to be published on NPM.\n\n## Requirements\n\nThe library works by pushing and retrieving messages from the message broker identified by the environment variable `MESSAGE_BROKER`.\n`MESSAGE_BROKER` can be whatever you use to identify the message broker host (IP address or hostname).\nThe optional environment variables `RABBITMQ_USER` and `RABBITMQ_PASS` are used to authenticate to the `MESSAGE_BROKER`.\nDocker Secrets are supported for storing `RABBITMQ_USER` and `RABBITMQ_PASS`;\n\nIf you're using docker, it's enough to define the env variables into the docker-compose.yml:\n```\n  environment:\n    - MESSAGE_BROKER=rabbitmq # in this case rabbitmq is the name of another container\n    - RABBITMQ_USER=username\n    - RABBITMQ_PASS=password\n```\n\n## Usage\n\nThe aim of the library is to ease AMQP messaging configuration and execution by:\n\n  - removing the overhead of the AMQP connection configuration;\n  - offering easy to use (and remember) functions.\n\n### Work Queue\n\n#### Push to a queue\n\n```\nconst mq = require('amqp-helper');\n\nmq.push({\n  queue: 'basket.save',\n  message: {\n    products: [4, 8, 15, 16, 23, 42],\n    total: 42\n  }\n});\n```\n\n#### Retrieve messages from a queue\n\n```\nconst mq = require('amqp-helper');\n\nmq.consume({\n  queue: 'basket.save',\n  callback: res => {\n    console.log(res.json);\n  }\n});\n```\n\n### Publish/Subscribe\n\nIn this case the communication is handled by defining an exchange instead of a queue.\n\n#### Publish a message\n\n```\nconst mq = require('amqp-helper');\n\nmq.pub({\n  exchange: 'order.billing-changed',\n  message: {\n    data: userData\n  }\n});\n```\n\n#### Consume a message\n\nMultiple consumers can subscribe to an exchange and get the same message\n\n```\nconst mq = require('amqp-helper');\n\nmq.sub({\n  exchange: 'order.billing-changed',\n  callback: res => {\n    console.log(res);\n  }\n});\n```\n\n### RPC\n\nRemote Procedure Call pattern can be easily set up by:\n\n#### Invoking an RPC\n\n```\nconst mq = require('amqp-helper');\n\nmq.rpc({\n  queue: 'user.get',\n  message: {\n    user_id: 3\n  }\n}).then(result => {\n  console.log(result);\n});\n```\n\n#### Listening for the RPC message\n\n```\nconst mq = require('amqp-helper');\n\nmq.consume({\n  queue: 'user.get',\n  callback: data => {\n\n    // Invoking RPC callback\n    data.channel.sendToQueue(\n      data.message.properties.replyTo,\n      Buffer.from(JSON.stringify({\n        userData: {\n          name: 'Douglas'\n        }\n      })),\n      {\n        correlationId: data.message.properties.correlationId\n      }\n    );\n\n  }\n});\n```\n\n## Todo\n\n  - Enhance documentation\n  - Code coverage\n\n## Contribution\n\n```\ncp .env.dist .env\ndocker-compose up -d\n./npm install\n./npm test\n```\n","versions":{"0.0.1-security":{"name":"amqp-helper","version":"0.0.1-security","description":"This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/npm/security-holder.git"},"keywords":[],"author":"","license":"ISC","bugs":{"url":"https://github.com/npm/security-holder/issues"},"homepage":"https://github.com/npm/security-holder#readme","_id":"amqp-helper@0.0.1-security","_shasum":"8163b24dc627ba748f9f94741472a58e53902fa7","_from":".","_npmVersion":"4.2.0","_nodeVersion":"4.1.2","_npmUser":{"name":"ehsalazar","email":"ernie@npmjs.com"},"dist":{"shasum":"8163b24dc627ba748f9f94741472a58e53902fa7","tarball":"https://registry.npmjs.org/amqp-helper/-/amqp-helper-0.0.1-security.tgz","integrity":"sha512-Th3fZkWo9K2H9tdotXoHYH4kxKZKlgRYZDGZMT2JvUzxLTNvoiC7d6ntcy0oxNWeYasNsfswnHNV+W/YfVuNHA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBe9lJd9UuytNC6FUpEQi3txN4Qm3g03cz3KEpt8j+33AiAUi8crFsgZhtSHhYWDWgtwPefQK1ZE4IxDtejUBNizcA=="}]},"maintainers":[{"name":"ehsalazar","email":"ernie@npmjs.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/amqp-helper-0.0.1-security.tgz_1490195896322_0.020251983776688576"},"directories":{}},"1.0.0":{"name":"amqp-helper","version":"1.0.0","description":"A Node.js helper for AMQP messaging.","main":"index.js","directories":{"lib":"lib","test":"test"},"scripts":{"test":"mocha"},"author":"","license":"ISC","dependencies":{"amqplib":"^0.5.2"},"devDependencies":{"mocha":"^5.2.0"},"gitHead":"f84465af3bca58d7ecf66183f5f00bc8b17fea16","_id":"amqp-helper@1.0.0","_npmVersion":"6.1.0","_nodeVersion":"10.4.1","_npmUser":{"name":"a.carbone","email":"ale.carbo@gmail.com"},"dist":{"integrity":"sha512-B59Hc1PtG9lOFw48nPkVAQeAXH4YaQfXAZciNuMfnc1vPrwv54rVWonVSPecuA0N4DB10VwHz9V3CF5jzbZL/Q==","shasum":"f86000222efa60ec98e7ae10331c3b9998f255a7","tarball":"https://registry.npmjs.org/amqp-helper/-/amqp-helper-1.0.0.tgz","fileCount":14,"unpackedSize":9413,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcPYhzCRA9TVsSAnZWagAAfhoP+wZ1IUmE3rq0gO7M0fSS\nyUwPlcKdaMrhAXynepTSXJdljOlZedBWbBjhbUVqXs9UFMFrah0mUh8VOSua\nu7jSrcQMDwRRFY2QkLJMuZNEdRb5WHDicQzWnlRSPOBg/WBe18BbQSjaHxLT\nM8KEAO6yafAgfED6W6S/wvZE8o5vHNymrJDvE8tfiLZl43mNuolcCqJPXF4H\nyiJOk0JAKTJCplXOhP8Ef+Bb6tD5GegRDkoQoQuXOE2IyDSJYX/lXMzKVfrO\nXOQz9LfQFKNrFXlTJncTuEYGt8xjBnwP7EXSNtfv5tNDcgHCHS8shm04PWac\nvHRiTnloNHDEYWqJfIre0v615zjq+sT3Fl5n4wRubuejroe/VxJAE2075YaI\nWBVnuRR69Hocuhg+05ktIOY6zHiEeNHctPdnrTK2ZckxfJxPIMF/L8KaRv4c\nG08zz1h3obKefd6hD1FEuhk/b3I/SkwTTnCUVtbS3GNGfMzVzQVLG2iZBjz5\nXv4ofNSpSuikjHTIEkrLXIvAJTu6bWe0ht1FO3olPIvTIbZpdINfULAnZwAG\nb/qXsoacd0ULdjel0vGHMFcHlr5f0wnSM64byaxi/oNlbKufTlrZEqhaFD3g\n6DCA0G65XhaaVkQ2M2bD1+/3VDoKGuwyiEl566szJdElNeGuzm3HhCpa+EaI\ndSya\r\n=gWt/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC+2USZxQKHlJJSvJDL6EKVAYCt2Wkdzk1UwJFb7BT1nAiEAnUT6UfjCJb+PUGlraRO0FIJ1vkZm8W28lUw0TnE3WRo="}]},"maintainers":[{"email":"ale.carbo@gmail.com","name":"a.carbone"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/amqp-helper_1.0.0_1547536498934_0.6288150363258194"},"_hasShrinkwrap":false}},"license":"ISC","readmeFilename":"README.md"}