Skip to content

Commit 548bcd3

Browse files
committed
Stream queue example
1 parent 51eb899 commit 548bcd3

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

examples/stream.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { AMQPClient } from '../lib/mjs/amqp-client.js'
2+
3+
async function run() {
4+
const amqp = new AMQPClient("amqp://localhost")
5+
const conn = await amqp.connect()
6+
let ch = await conn.channel()
7+
await ch.prefetch(100)
8+
let q = await ch.queue("stream1", {}, {"x-queue-type": "stream" })
9+
const consumer = await q.subscribe({noAck: false, args: {"x-stream-offset": "first"}}, (msg) => {
10+
console.log(msg.bodyString())
11+
msg.ack()
12+
})
13+
await consumer.wait()
14+
}
15+
await run()

0 commit comments

Comments
 (0)