-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathamqp-publisher.ts
More file actions
28 lines (25 loc) · 855 Bytes
/
amqp-publisher.ts
File metadata and controls
28 lines (25 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { AMQPProperties } from "./amqp-properties.js"
import type { AMQPSession } from "./amqp-session.js"
export type Body = string | Uint8Array | ArrayBuffer | Buffer | null
/** Publish with broker confirmation. */
export async function publishConfirmed(
session: AMQPSession,
exchange: string,
routingKey: string,
body: Body,
properties?: AMQPProperties,
): Promise<void> {
const ch = await session.getConfirmChannel()
await ch.basicPublish(exchange, routingKey, body, properties ?? {})
}
/** Publish without waiting for broker confirmation. */
export async function publishNoConfirm(
session: AMQPSession,
exchange: string,
routingKey: string,
body: Body,
properties?: AMQPProperties,
): Promise<void> {
const ch = await session.getOpsChannel()
await ch.basicPublish(exchange, routingKey, body, properties ?? {})
}