{"_id":"@cowood/service-bus","_rev":"2-bed46cddaf4ca896d82e0453b3f6d4f2","name":"@cowood/service-bus","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.4":{"name":"@cowood/service-bus","sdk-type":"client","author":{"name":"Microsoft Corporation"},"version":"1.0.4","license":"MIT","description":"Azure Service Bus SDK for Node.js","homepage":"https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/servicebus/service-bus","repository":{"type":"git","url":"git+https://github.com/Azure/azure-sdk-for-js.git"},"keywords":["azure","cloud","service bus","AMQP"],"bugs":{"url":"https://github.com/azure/azure-sdk-for-js/issues"},"main":"./dist/index.js","module":"dist-esm/src/index.js","browser":{"./dist/index.js":"./browser/service-bus.js","./dist-esm/test/utils/aadUtils.js":"./dist-esm/test/utils/aadUtils.browser.js","buffer":"buffer","stream":"stream-browserify"},"types":"./typings/service-bus.d.ts","engine":{"node":">=6.0.0"},"scripts":{"audit":"node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit","build:browser":"tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1","build:node":"tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1","build:samples":"node .scripts/prepSamples.js && cd samples && tsc -p .","build:test:browser":"tsc -p . && cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1","build:test:node":"tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1","build:test":"npm run build:test:node && npm run build:test:browser","build":"tsc -p . && rollup -c 2>&1 && npm run extract-api","check-format":"prettier --list-different --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"","clean":"rimraf dist dist-esm test-dist typings *.tgz *.log coverage coverage-browser .nyc_output","coverage":"nyc --reporter=lcov --exclude-after-remap=false mocha -t 120000 test-dist/index.js --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-","extract-api":"tsc -p . && api-extractor run --local","format":"prettier --write --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"","integration-test:browser":"node .scripts/buildBrowserTestResources.js && karma start --single-run","integration-test:node":"mocha -t 120000 test-dist/index.js --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-","integration-test":"npm run integration-test:node && npm run integration-test:browser","lint":"eslint -c ../../.eslintrc.json src test samples --ext .ts -f html -o service-bus-lintReport.html || exit 0","lint-fix":"eslint -c ../../.eslintrc.json src test samples --ext .ts --fix --fix-type [problem,suggestion]","pack":"npm pack 2>&1","prebuild":"npm run clean","test:browser":"npm run build:test:browser && npm run integration-test:browser","test:node":"npm run build:test:node && npm run integration-test:node","test":"npm run test:node && npm run test:browser","unit-test:browser":"echo skipped","unit-test:node":"echo skipped","unit-test":"npm run unit-test:node && npm run unit-test:browser"},"sideEffects":false,"dependencies":{"@azure/amqp-common":"1.0.0-preview.6","@azure/ms-rest-nodeauth":"^0.9.2","@types/is-buffer":"^2.0.0","@types/long":"^4.0.0","buffer":"^5.2.1","debug":"^4.1.1","is-buffer":"^2.0.3","long":"^4.0.0","process":"^0.11.10","rhea":"^1.0.4","rhea-promise":"^0.1.15","tslib":"^1.9.3"},"devDependencies":{"@azure/arm-servicebus":"^3.2.0","@microsoft/api-extractor":"^7.1.5","@types/async-lock":"^1.1.0","@types/chai":"^4.1.6","@types/chai-as-promised":"^7.1.0","@types/debug":"^4.1.4","@types/dotenv":"^6.1.0","@types/mocha":"^5.2.5","@types/node":"^8.0.0","@types/ws":"^6.0.1","@typescript-eslint/eslint-plugin":"^2.0.0","@typescript-eslint/parser":"^2.0.0","assert":"^1.4.1","chai":"^4.2.0","chai-as-promised":"^7.1.1","cross-env":"^5.2.0","delay":"^4.2.0","dotenv":"^8.0.0","eslint":"^6.1.0","eslint-config-prettier":"^6.0.0","eslint-plugin-no-null":"^1.0.2","eslint-plugin-no-only-tests":"^2.3.0","eslint-plugin-promise":"^4.1.1","https-proxy-agent":"^2.2.1","karma":"^4.0.1","karma-chrome-launcher":"^3.0.0","karma-coverage":"^1.1.2","karma-edge-launcher":"^0.4.2","karma-env-preprocessor":"^0.1.1","karma-firefox-launcher":"^1.1.0","karma-ie-launcher":"^1.0.0","karma-junit-reporter":"^1.2.0","karma-mocha":"^1.3.0","karma-mocha-reporter":"^2.2.5","karma-remap-coverage":"^0.1.5","mocha":"^6.2.0","mocha-junit-reporter":"^1.18.0","mocha-multi":"^1.1.3","moment":"^2.24.0","nyc":"^14.0.0","prettier":"^1.16.4","promise":"^8.0.3","puppeteer":"^1.11.0","rimraf":"^3.0.0","rollup":"^1.16.3","rollup-plugin-commonjs":"^10.0.0","rollup-plugin-inject":"^3.0.0","rollup-plugin-json":"^4.0.0","rollup-plugin-multi-entry":"^2.1.0","rollup-plugin-node-resolve":"^5.0.2","rollup-plugin-replace":"^2.1.0","rollup-plugin-shim":"^1.0.0","rollup-plugin-sourcemaps":"^0.4.2","rollup-plugin-terser":"^5.1.1","ts-node":"^8.3.0","typescript":"^3.2.2","ws":"^7.1.1"},"_id":"@cowood/service-bus@1.0.4","_npmVersion":"6.5.0","_nodeVersion":"11.6.0","_npmUser":{"name":"cowood","email":"Connor.Wood@microsoft.com"},"dist":{"integrity":"sha512-MrX5Ksw3io5MhZxCxQ1KueI6PQKZPJHucNNdeSZYDi6n+g9YOZW2AAJpe7jOZqb93/Fx73qq1+KfC5Ik1ICCBA==","shasum":"1b39f28c1a2e5990bc56c7285c5e9994a9010680","tarball":"https://registry.npmjs.org/@cowood/service-bus/-/service-bus-1.0.4.tgz","fileCount":80,"unpackedSize":889934,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdaXLFCRA9TVsSAnZWagAAzsQP/A+B+qLB3Wo5e5MD/Cnr\nK3wt6NQaX915DT4adHTImFJ5SOYZBjvWetd163MnaHWBdadkZfdAwWJapCxq\njuPCzBS7YfY2Lu1GyYye7N4VNIqnc9i/7Si1MjlWEi0HoIuuLaaRdlD3GsJK\n5j2pW4RzUZDVjLgqdYCUDdwQ9VG5pkJjzRNUlQhjD8nTMtC7bPuaOAHZUtSz\nWQoqj/t6akoFZKSpemCYuYXEP6qh/8RZM4gY3GqtM4B5mnJIGux9YX1f8Xc5\nkDD2V6u0ET2U3aUWTJkLpFSOTFcv9HTbc7NIx8ob2R7t3HGxaayXqZ//tLm9\nNljYtpl9w4nwrx4zgD3BS/mvfkbFH0YRJhnnHRyXLI3SnL5d+qjgnFa+Mfyo\ntEYEFBUod76/IgM9yT5ExW/DvmYhvfbc24vHfFaHlSqCf5bp3+X5jBMsQ9Ik\nZv68M452XD6QNqdyedeyfL+BzkJnJ1Y2HPbMhglbczuT6ILSGbwOAaLYUvRc\nT0CH2EBOz0EeBSIfcJSnkE/QJgtZPBRvK4AIJHZ9PDcZKUNkfKd/VVEoZzL1\ne50NjGRgFcPi34a0Yju/e5dlmWxT6xpcm3hkyqXj/JH9498aEHHKUzhSOnzW\nfQVPzdK1bsBkAgX7kCNe7Xynld5R9u2NzDT//hkbReidAeh81TOqRY/edMm5\neDEm\r\n=wp61\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGJl6eGQ3hNiXzL3JhaoddSpMH+nIIh4Gdl3950c3c3yAiEAsusz4EjQYkW9JdvYdcU0YyUh0mnbmj+zCvzx/7TexuA="}]},"maintainers":[{"name":"cowood","email":"Connor.Wood@microsoft.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/service-bus_1.0.4_1567191748370_0.5976888110868968"},"_hasShrinkwrap":false},"1.0.5":{"name":"@cowood/service-bus","sdk-type":"client","author":{"name":"Microsoft Corporation"},"version":"1.0.5","license":"MIT","description":"Azure Service Bus SDK for Node.js","homepage":"https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/servicebus/service-bus","repository":{"type":"git","url":"git+https://github.com/Azure/azure-sdk-for-js.git"},"keywords":["azure","cloud","service bus","AMQP"],"bugs":{"url":"https://github.com/azure/azure-sdk-for-js/issues"},"main":"./dist/index.js","module":"dist-esm/src/index.js","browser":{"./dist/index.js":"./browser/service-bus.js","./dist-esm/test/utils/aadUtils.js":"./dist-esm/test/utils/aadUtils.browser.js","buffer":"buffer","stream":"stream-browserify"},"types":"./typings/service-bus.d.ts","engine":{"node":">=6.0.0"},"scripts":{"audit":"node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit","build:browser":"tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1","build:node":"tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1","build:samples":"node .scripts/prepSamples.js && cd samples && tsc -p .","build:test:browser":"tsc -p . && cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1","build:test:node":"tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1","build:test":"npm run build:test:node && npm run build:test:browser","build":"tsc -p . && rollup -c 2>&1 && npm run extract-api","check-format":"prettier --list-different --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"","clean":"rimraf dist dist-esm test-dist typings *.tgz *.log coverage coverage-browser .nyc_output","coverage":"nyc --reporter=lcov --exclude-after-remap=false mocha -t 120000 test-dist/index.js --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-","extract-api":"tsc -p . && api-extractor run --local","format":"prettier --write --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"","integration-test:browser":"node .scripts/buildBrowserTestResources.js && karma start --single-run","integration-test:node":"mocha -t 120000 test-dist/index.js --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-","integration-test":"npm run integration-test:node && npm run integration-test:browser","lint":"eslint -c ../../.eslintrc.json src test samples --ext .ts -f html -o service-bus-lintReport.html || exit 0","lint-fix":"eslint -c ../../.eslintrc.json src test samples --ext .ts --fix --fix-type [problem,suggestion]","pack":"npm pack 2>&1","prebuild":"npm run clean","test:browser":"npm run build:test:browser && npm run integration-test:browser","test:node":"npm run build:test:node && npm run integration-test:node","test":"npm run test:node && npm run test:browser","unit-test:browser":"echo skipped","unit-test:node":"echo skipped","unit-test":"npm run unit-test:node && npm run unit-test:browser"},"sideEffects":false,"dependencies":{"@azure/amqp-common":"1.0.0-preview.6","@azure/ms-rest-nodeauth":"^0.9.2","@types/is-buffer":"^2.0.0","@types/long":"^4.0.0","buffer":"^5.2.1","debug":"^4.1.1","is-buffer":"^2.0.3","long":"^4.0.0","process":"^0.11.10","rhea":"^1.0.4","rhea-promise":"^0.1.15","tslib":"^1.9.3"},"devDependencies":{"@azure/arm-servicebus":"^3.2.0","@microsoft/api-extractor":"^7.1.5","@types/async-lock":"^1.1.0","@types/chai":"^4.1.6","@types/chai-as-promised":"^7.1.0","@types/debug":"^4.1.4","@types/dotenv":"^6.1.0","@types/mocha":"^5.2.5","@types/node":"^8.0.0","@types/ws":"^6.0.1","@typescript-eslint/eslint-plugin":"^2.0.0","@typescript-eslint/parser":"^2.0.0","assert":"^1.4.1","chai":"^4.2.0","chai-as-promised":"^7.1.1","cross-env":"^5.2.0","delay":"^4.2.0","dotenv":"^8.0.0","eslint":"^6.1.0","eslint-config-prettier":"^6.0.0","eslint-plugin-no-null":"^1.0.2","eslint-plugin-no-only-tests":"^2.3.0","eslint-plugin-promise":"^4.1.1","https-proxy-agent":"^2.2.1","karma":"^4.0.1","karma-chrome-launcher":"^3.0.0","karma-coverage":"^1.1.2","karma-edge-launcher":"^0.4.2","karma-env-preprocessor":"^0.1.1","karma-firefox-launcher":"^1.1.0","karma-ie-launcher":"^1.0.0","karma-junit-reporter":"^1.2.0","karma-mocha":"^1.3.0","karma-mocha-reporter":"^2.2.5","karma-remap-coverage":"^0.1.5","mocha":"^6.2.0","mocha-junit-reporter":"^1.18.0","mocha-multi":"^1.1.3","moment":"^2.24.0","nyc":"^14.0.0","prettier":"^1.16.4","promise":"^8.0.3","puppeteer":"^1.11.0","rimraf":"^3.0.0","rollup":"^1.16.3","rollup-plugin-commonjs":"^10.0.0","rollup-plugin-inject":"^3.0.0","rollup-plugin-json":"^4.0.0","rollup-plugin-multi-entry":"^2.1.0","rollup-plugin-node-resolve":"^5.0.2","rollup-plugin-replace":"^2.1.0","rollup-plugin-shim":"^1.0.0","rollup-plugin-sourcemaps":"^0.4.2","rollup-plugin-terser":"^5.1.1","ts-node":"^8.3.0","typescript":"^3.2.2","ws":"^7.1.1"},"_id":"@cowood/service-bus@1.0.5","_npmVersion":"6.5.0","_nodeVersion":"11.6.0","_npmUser":{"name":"cowood","email":"Connor.Wood@microsoft.com"},"dist":{"integrity":"sha512-+UGJ6baCFuwIFMdXfoeUhkIN+JUnmsklAPUp65E2Z30qWVF1kM5wKXUgIl+D+/LALaaIx8wOXU4Cv8gfgCpz6Q==","shasum":"966deb5e00681abe62c82dd43de01a0829cb3e07","tarball":"https://registry.npmjs.org/@cowood/service-bus/-/service-bus-1.0.5.tgz","fileCount":83,"unpackedSize":1813083,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdaYZcCRA9TVsSAnZWagAA/CAP/3p66IxsyobUifC8xehX\niLohOItL9sQaWrEKbp1jIvS3FGw2JM0JyayUJ7U9SD7Kw9pfU3ucvOzEvDa5\nioCrpmIzdiI5Vd4FvYmt8YbD4tmgE9eB2qixjSHehD8IixW5JHe2BJGMA4uh\nF2txBbKigu2jsiM0tn3Rf06S8wYloFjG5U7ikCXcWbqq64Ry0G1ZTAb8Sr0u\n5PwmuLxtpXvc/LwOAgOtye5KlYSvNn+jBB69HtqWfldzXNiVASrfoaJLecNy\n/0WDS+1hxFpNKb8Hu3jvFN9H/YASUGg1s89RzmagH/P/azz3YRdYBNc7ecj1\nrj2+/jaxcrhuWECEMWfT47Nko+ONB0suLaKsANEwm/klCiYIXv18htpGfmho\nentjbzD+E8QA3CB3lPDo91+DYJPnuGKNGm5kjqcSAQvQd2vQSsdp94bnki8D\nC81DO09iLt8MDkuyuvDg7Jcugqo+Ta3eNrGwTdcMoRxZlmP0SegMASawCYk0\nuN6EDg+RzcVexBg4Kr0K+DOigGIgACduc9Cxv2j8eNRJZWZnLEOCWYSn/e4/\nhLD3Dl1wn8fltGv83wHzPBWK4s+elwbKT+N1nMdVdjAqZlXKjtjIlIJe1hX3\nZCt4giyQR+5L33Rqcuz2C1DwpvCwk3PV22tKBV5Uj3sQ/NeHE1zqdxrWYyxE\nbe7l\r\n=CK15\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFjmMrYsriMf2fnt5Y008/Vb9aS8QqISc7E761DC9zOEAiEAnW4sSGZ4pU8cjHDjKNIj8gNPbfbOTn888G8tLZ56r4Y="}]},"maintainers":[{"name":"cowood","email":"Connor.Wood@microsoft.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/service-bus_1.0.5_1567196764265_0.37201978618943565"},"_hasShrinkwrap":false}},"time":{"created":"2019-08-30T19:02:28.149Z","1.0.4":"2019-08-30T19:02:28.527Z","modified":"2022-04-05T01:31:07.788Z","1.0.5":"2019-08-30T20:26:04.395Z"},"maintainers":[{"name":"cowood","email":"Connor.Wood@microsoft.com"}],"description":"Azure Service Bus SDK for Node.js","homepage":"https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/servicebus/service-bus","keywords":["azure","cloud","service bus","AMQP"],"repository":{"type":"git","url":"git+https://github.com/Azure/azure-sdk-for-js.git"},"author":{"name":"Microsoft Corporation"},"bugs":{"url":"https://github.com/azure/azure-sdk-for-js/issues"},"license":"MIT","readme":"# Azure Service Bus client library for Javascript\n\nAzure Service Bus is a highly-reliable cloud messaging service from Microsoft\n\nUse the client library for Azure Service Bus in your Node.js application to\n\n- Send messages to a Queue or Topic\n- Receive messages from a Queue or Subscription\n\n[Source code](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/servicebus/service-bus) | [Package (npm)](https://www.npmjs.com/package/@azure/service-bus) | [API Reference Documentation](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/) | [Product documentation](https://azure.microsoft.com/en-us/services/service-bus/) | [Samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/servicebus/service-bus/samples)\n\n## Getting Started\n\n### Install the package\n\nInstall the Azure Service Bus client library using npm\n\n`npm install @azure/service-bus`\n\n**Prerequisites**: You must have an [Azure subscription](https://azure.microsoft.com/free/) and a\n[Service Bus Namespace](https://docs.microsoft.com/en-us/azure/service-bus-messaging/) to use this package.\nIf you are using this package in a Node.js application, then use Node.js 6.x or higher.\n\n### Configure Typescript\n\nTypeScript users need to have Node type definitions installed:\n\n```bash\nnpm install @types/node\n```\n\nYou also need to enable `compilerOptions.allowSyntheticDefaultImports` in your tsconfig.json. Note that if you have enabled `compilerOptions.esModuleInterop`, `allowSyntheticDefaultImports` is enabled by default. See [TypeScript's compiler options handbook](https://www.typescriptlang.org/docs/handbook/compiler-options.html) for more information.\n\n### Authenticate the client\n\nInteraction with Service Bus starts with an instance of the [ServiceBusClient](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/servicebusclient) class. You can instantiate\nthis class using one of the 3 static methods on it\n\n- [createFromConnectionString](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/servicebusclient#createfromconnectionstring-string--servicebusclientoptions-)\n  - This method takes the connection string to your Service Bus instance. You can get the connection string\n    from the Azure portal.\n- [createFromTokenProvider](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/servicebusclient#createfromtokenprovider-string--tokenprovider--servicebusclientoptions-)\n  - This method takes the host name of your Service Bus instance and your custom implementation of the [TokenProvider](https://github.com/Azure/amqp-common-js/blob/master/lib/auth/token.ts) interface.The host name is of the format `name-of-service-bus-instance.servicebus.windows.net`.\n- [createFromAADTokenCredentials](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/servicebusclient#createfromaadtokencredentials-string--applicationtokencredentials---usertokencredentials---devicetokencredentials---msitokencredentials--servicebusclientoptions-)\n  - This method takes the host name of your Service Bus instance and a credentials object that you need\n    to generate using the [@azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth)\n    library. The host name is of the format `name-of-service-bus-instance.servicebus.windows.net`.\n  - Refer to the samples that use an [Azure account](https://github.com/Azure/azure-sdk-for-js/blob/%40azure/service-bus_1.0.0/sdk/servicebus/service-bus/samples/javascript/gettingStarted/loginWithAzureAccount.js), [interactive login](https://github.com/Azure/azure-sdk-for-js/blob/%40azure/service-bus_1.0.0/sdk/servicebus/service-bus/samples/javascript/gettingStarted/interactiveLogin.js) or [service principal](https://github.com/Azure/azure-sdk-for-js/blob/%40azure/service-bus_1.0.0/sdk/servicebus/service-bus/samples/javascript/gettingStarted/servicePrincipalLogin.js)\n\n### Key concepts\n\nOnce you have initialized the [ServiceBusClient](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/servicebusclient) class, use the below methods to create client\nobjects for Queues, Topics and Subscriptions to interact with existing Service Bus entities. Please\nnote that the Queues, Topics and Subscriptions should already have been created prior to using this\nlibrary.\n\n- [createQueueClient](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/servicebusclient#createqueueclient-string-)\n  - Takes the name of an existing Service Bus Queue instance, returns a QueueClient that you can use\n    to send to and receive messages from the queue.\n- [createTopicClient](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/servicebusclient#createtopicclient-string-)\n  - Takes the name of an existing Service Bus Topic instance, returns a TopicClient that you can use\n    to send messages to the topic\n- [createSubscriptionClient](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/servicebusclient#createsubscriptionclient-string--string-)\n  - Takes the name of existing Service Bus Topic and Subscription instances, returns a SubscriptionClient\n    that you can use to receive messages from the subscription.\n\nNext, using the client object created in the previous step, create a sender or a receiver based on\nwhether you want to send or receive messages\n\n### Examples\n\nThe following sections provide code snippets that cover some of the common tasks using Azure Service Bus\n\n- [Send messages](#send-messages)\n- [Receive messages](#receive-messages)\n- [Settle a message](#settle-a-message)\n- [Send messages using Sessions](#send-messages-using-sessions)\n- [Receive messages using Sessions](#receive-messages-using-sessions)\n\n### Send messages\n\nOnce you have created an instance of a `QueueClient` or `SubscriptionClient` class, create a sender\nusing the [createSender](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/queueclient#createsender--)\nfunction. This gives you a sender which you can use to [send](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/sender#send-sendablemessageinfo-) messages.\n\nYou can also use the [sendBatch](https://docs.microsoft.com/en-us/javascript/api/@azure/service-bus/sender#sendbatch-sendablemessageinfo---) method to send multiple messages using a single call.\n\n```javascript\nconst queueClient = serviceBusClient.createQueueClient(\"my-queue\");\nconst sender = queueClient.createSender();\nawait sender.send({\n  body: \"my-message-body\"\n});\nawait sender.sendBatch([\n  { body: \"my-message-body-1\" },\n  { body: \"my-message-body-2\" },\n  { body: \"my-message-body-3\" }\n]);\n```\n\n### Receive messages\n\nOnce you have created an instance of a `QueueClient` or `SubscriptionClient` class, create a receiver\nusing the [createReceiver](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/queueclient#createreceiver-receivemode-) function.\n\n```javascript\nconst queueClient = serviceBusClient.createQueueClient(\"my-queue\");\nconst receiver = queueClient.createReceiver(ReceiveMode.peekLock);\n```\n\nYou can use this receiver in one of 3 ways to receive messages:\n\n#### Get an array of messages\n\nUse the [receiveMessages](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/receiver#receivemessages-number--number-) function which returns a promise that\nresolves to an array of messages.\n\n```javascript\nconst myMessages = await receiver.receiveMessages(10);\n```\n\n#### Register message handler\n\nUse the [registerMessageHandler](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/receiver#registermessagehandler-onmessage--onerror--messagehandleroptions-) to set up\nmessage handlers and have it running as long as you\nneed. When you are done, call `receiver.close()` to stop receiving any more messages.\n\n```javascript\nconst myMessageHandler = async (message) => {\n  // your code here\n};\nconst myErrorHandler = (error) => {\n  console.log(error);\n};\nreceiver.registerMessageHandler(myMessageHandler, myErrorHandler);\n```\n\n#### Use async iterator\n\nUse the [getMessageIterator](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/receiver#getmessageiterator--) to get an async iterator over messages\n\n```javascript\nfor await (let message of receiver.getMessageIterator()){\n  // your code here\n}\n```\n\n### Settle a message\n\nOnce you receive a message you can call `complete()`, `abandon()`, `defer()` or `deadletter()` on it\nbased on how you want to settle the message. To learn more, please read [Settling Received Messages](https://docs.microsoft.com/en-us/azure/service-bus-messaging/message-transfers-locks-settlement#settling-receive-operations)\n\n### Send messages using Sessions\n\nTo send messages using sessions, you first need to create a session enabled Queue. You can do this\nin the Azure portal. Then, use an instance of `QueueClient` to create a sender\nusing the [createSender](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/queueclient#createsender--)\nfunction. This gives you a sender which you can use to [send](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/sender#send-sendablemessageinfo-) messages.\n\nWhen sending the message, set the `sessionId` property in the message body to ensure your message\nlands in the right session.\n\n```javascript\nconst queueClient = serviceBusClient.createQueueClient(\"my-session-queue\");\nconst sender = queueClient.createSender();\nawait sender.send({\n  body: \"my-message-body\",\n  sessionId: \"my-session\"\n});\n```\n\n### Receive messages from Sessions\n\nTo receive messages from sessions, you first need to create a session enabled Queue and send messages\nto it. Then, use an instance of `QueueClient` or `SubscriptionClient` to create a receiver\nusing the [createReceiver](https://docs.microsoft.com/en-us/javascript/api/%40azure/service-bus/queueclient#createreceiver-receivemode--sessionreceiveroptions-) function. Note\nthat you will need to specify the session from which you want to receive messages.\n\n```javascript\nconst queueClient = serviceBusClient.createQueueClient(\"my-session-queue\");\nconst receiver = queueClient.createReceiver(ReceiveMode.peekLock, { sessionId: \"my-session\" });\n```\n\nYou can use this receiver in one of 3 ways to receive messages\n\n- [Get an array of messages](#get-an-array-of-messages)\n- [Register message handler](#register-message-handler)\n- [Use async iterator](#use-async-iterator)\n\n## Troubleshooting\n\n## AMQP Dependencies ##\nThe Service Bus library depends on the [rhea-promise](https://github.com/amqp/rhea-promise) library for managing connections, sending and receiving messages over the [AMQP](http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-complete-v1.0-os.pdf) protocol.\n\n### Enable logs\n\nYou can set the following environment variable to get the debug logs when using this library.\n\n- Getting debug logs from the Service Bus SDK\n\n```bash\nexport DEBUG=azure*\n```\n\n- Getting debug logs from the Service Bus SDK and the protocol level library.\n\n```bash\nexport DEBUG=azure*,rhea*\n```\n\n- If you are **not interested in viewing the message transformation** (which consumes lot of console/disk space) then you can set the `DEBUG` environment variable as follows:\n\n```bash\nexport DEBUG=azure*,rhea*,-rhea:raw,-rhea:message,-azure:amqp-common:datatransformer\n```\n\n- If you are interested only in **errors**, then you can set the `DEBUG` environment variable as follows:\n\n```bash\nexport DEBUG=azure:service-bus:error,azure-amqp-common:error,rhea-promise:error,rhea:events,rhea:frames,rhea:io,rhea:flow\n```\n\n### Logging to a file\n\n- Set the `DEBUG` environment variable as shown above and then run your test script as follows:\n  - Logging statements from your test script go to `out.log` and logging statements from the sdk go to `debug.log`.\n    ```bash\n    node your-test-script.js > out.log 2>debug.log\n    ```\n  - Logging statements from your test script and the sdk go to the same file `out.log` by redirecting stderr to stdout (&1), and then redirect stdout to a file:\n    ```bash\n    node your-test-script.js >out.log 2>&1\n    ```\n  - Logging statements from your test script and the sdk go to the same file `out.log`.\n    ```bash\n      node your-test-script.js &> out.log\n    ```\n\n## Next Steps\n\nPlease take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/servicebus/service-bus/samples)\ndirectory for detailed examples on how to use this library to send and receive messages to/from\n[Service Bus Queues, Topics and Subscriptions](https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview).\n\n## Contributing\n\nIf you'd like to contribute to this library, please read the [contributing guide](../../../CONTRIBUTING.md) to learn more about how to build and test the code.\n\n![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/servicebus/service-bus/README.png)\n","readmeFilename":"README.md"}