# @level-two/rabbitmq

> RabbitMQ broadcast extension of level two

Latest version **2.0.0** (published 2023-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @level-two/rabbitmq
pnpm add @level-two/rabbitmq
yarn add @level-two/rabbitmq
bun add @level-two/rabbitmq
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-07-17 |
| First published | 2023-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 20.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Corey Hart |
| Maintainers | codenothing |
| Keywords | cache, memory, util, rabbitmq, level-two |

## Links

- npm: https://www.npmjs.com/package/@level-two/rabbitmq
- Repository: https://github.com/codenothing/level-two
- Homepage: https://github.com/codenothing/level-two#readme
- Issues: https://github.com/codenothing/level-two/issues
- npm.io page: https://npm.io/package/@level-two/rabbitmq

## Dependencies (3)

- [amqplib](https://npm.io/package/amqplib.md) ^0.10.3
- [@types/amqplib](https://npm.io/package/@types/amqplib.md) ^0.10.1
- [@level-two/core](https://npm.io/package/@level-two/core.md) ^2.0.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2023-07-17
- 1.2.0 — 2023-01-22
- 1.1.0 — 2023-01-04
- 1.0.0 — 2023-01-03

## README

# LevelTwo - RabbitMQ

A message broker extension for [LevelTwo](https://www.npmjs.com/package/@level-two/core). Refer to the [Worker API](https://www.npmjs.com/package/@level-two/core#worker-api) for function definitions.

## Usage

```ts
import { createLevelTwoRabbitMQ } from "@level-two/rabbitmq";

// Integrates RabbitMQ message broker into a LevelTwo instance
const levelTwo = createLevelTwoRabbitMQ({
  url: "amqp://localhost:5673/",
});

// Create a worker for getting cacheable customer objects
const worker = levelTwo.createWorker("customer", async (ids, earlyWrite) => {
  const rows = await mysql.query(
    "SELECT id, name FROM customers WHERE id IN (?)",
    [ids]
  );

  rows.forEach((row) => earlyWrite(row.id, row));
});

// Service method for getting a single customer
export async function getCustomer(id: string): Promise<Customer> {
  return await worker.get(id);
}

// Service method for getting a list of customers
export async function getCustomerList(ids: string[]): Promise<Customer[]> {
  return await worker.getMulti(ids);
}
```

## Settings

### `url`

Endpoint for connecting client to

### `broadcastChannel`

Broadcast channel name for sending/receiving actions

### `consumeOptions`

Options when adding consumer listener

### `consumerExchangeOptions`

Options when declaring the consumer exchange

### `consumerQueueOptions`

Options when declaring the consumer queue

### `publishOptions`

Options when publishing a message

### `publisherExchangeOptions`

Options when declaring the publisher exchange

### `remoteCache`

LevelTwo remote cache extension

### `cacheDefaults`

LevelTwo worker cache defaults

---
_Source: https://npm.io/package/@level-two/rabbitmq · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
