This library is deprecated and no longer maintained.
Deno runs Node packages now, so a Deno-specific AMQP client is no longer needed. Use one of these instead:
amqplib—import amqp from "npm:amqplib"@cloudamqp/amqp-client—import { AMQPClient } from "npm:@cloudamqp/amqp-client", if you want a TypeScript-native APIBoth connect to RabbitMQ over
amqp://andamqps://.Existing
https://deno.land/x/amqpimports will keep working — those URLs are immutable. But this library does not type check on Deno 2, since it depends on the removedDeno.Reader,Deno.WriterandDeno.Closertypes.
AMQP 0.9.1 implementation for https://deno.land/. The library is implemented to connect to a RabbitMQ broker. For testing purposes, an instance can be started using docker:
docker run -d --rm -p 15672:15672 -p 5672:5672 rabbitmq:3-management
import { connect } from "https://deno.land/x/amqp/mod.ts";
const connection = await connect();
const channel = await connection.openChannel();
const queueName = "my.queue";
await channel.declareQueue({ queue: queueName });
await channel.consume(
{ queue: queueName },
async (args, props, data) => {
console.log(JSON.stringify(args));
console.log(JSON.stringify(props));
console.log(new TextDecoder().decode(data));
await channel.ack({ deliveryTag: args.deliveryTag });
},
);import { connect } from "https://deno.land/x/amqp/mod.ts";
const connection = await connect();
const channel = await connection.openChannel();
const queueName = "my.queue";
await channel.declareQueue({ queue: queueName });
await channel.publish(
{ routingKey: queueName },
{ contentType: "application/json" },
new TextEncoder().encode(JSON.stringify({ foo: "bar" })),
);
await connection.close();See examples/. Start the example consumer by running
deno run --allow-net examples/consume_message.ts queue
Then, send a message to the same queue using the default exchange using the example publisher
deno run --allow-net examples/publish_message.ts queue
See autogenerated deno docs at: https://doc.deno.land/https/deno.land/x/amqp/mod.ts
Run unit tests
deno test src/
Run module tests (requires an AMQP broker running on localhost)
deno test --allow-net module_test/