|
1 | 1 | # [WIP] RabbitMQ AMQP 1.0 JavaScript Client |
2 | 2 |
|
| 3 | +# NOT READY FOR PRODUCTION - The client is HEAVILY work in progress. |
| 4 | + |
| 5 | +[](https://github.com/coders51/rabbitmq-amqp-js-client/actions) |
| 6 | + |
| 7 | +This library is meant to be used with RabbitMQ 4.0. |
| 8 | + |
| 9 | +# Table of Contents |
| 10 | + |
| 11 | +- [Installing via NPM](#installing-via-npm) |
| 12 | + |
| 13 | +- [Getting started](#getting-started) |
| 14 | + |
| 15 | +- [Resources](#resources) |
| 16 | + |
| 17 | +## Installing via npm |
| 18 | + |
| 19 | +The client is distributed via **npm**: |
| 20 | + |
| 21 | +```bash |
| 22 | + npm install rabbitmq-amqp-js-client |
| 23 | +``` |
| 24 | + |
| 25 | +## Getting started |
| 26 | + |
| 27 | +**NOTE:** this is just a first example and will be replaced with the reference to the _examples folder_ |
| 28 | + |
| 29 | +```typescript |
| 30 | +const environment = createEnvironment({ |
| 31 | + host: "localhost", |
| 32 | + port: 5672, |
| 33 | + username: "rabbit", |
| 34 | + password: "rabbit", |
| 35 | +}) |
| 36 | + |
| 37 | +const connection = await environment.createConnection() |
| 38 | + |
| 39 | +const management = connection.management() |
| 40 | + |
| 41 | +const queue = await management.declareQueue("test") |
| 42 | + |
| 43 | +const exchange = await management.declareExchange("exchange", { type: "topic" }) |
| 44 | +const secondExchange = await management.declareExchange("exchange-dest", { type: "topic" }) |
| 45 | + |
| 46 | +const bindingToQueue = await management.bind("foo", { source: exchange, destination: queue }) |
| 47 | +const bindingToExchange = await management.bind("foo", { source: exchange, destination: secondExchange }) |
| 48 | + |
| 49 | +await management.unbind("foo", { source: exchange, destination: queue }) |
| 50 | +await management.unbind("foo", { source: exchange, destination: secondExchange }) |
| 51 | + |
| 52 | +await management.deleteExchange("exchange") |
| 53 | +await management.deleteExchange("exchange-dest") |
| 54 | +await management.deleteQueue("test") |
| 55 | + |
| 56 | +management.close() |
| 57 | +await connection.close() |
| 58 | +await environment.close() |
| 59 | +``` |
| 60 | + |
| 61 | +In this example we demonstrate how to create an environment, open a connection and use the management to create |
| 62 | +or delete queues, exchanges and bindings. |
| 63 | + |
3 | 64 | ## Resources |
4 | 65 |
|
5 | 66 | - [Reference library for AMQP 1.0](https://github.com/amqp/rhea) |
|
0 commit comments