Skip to main content

initQueue

function initQueue(config: Object = {})
async

Establishes a connection to a RabbitMQ server.

Returns: Promise<Object>

  • Resolves to a RabbitMQ connection instance.
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
configObject✔️AMQP connection configuration.
config.uristringThe AMQP server connection URI.
config.amqpOptionsObject✔️Additional amqplib socket options.
See the official amqplib package documentation for more details:

Throws: Error

Rejects if config.uri is missing or the connection fails.
See:

const conn = await initQueue({ uri: "amqp://localhost" });
const channel = await conn.createChannel();