initQueue
function initQueue(config: Object = {})
async
Establishes a connection to a RabbitMQ server.
Returns: Promise<Object>
- Resolves to a RabbitMQ connection instance.
| PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
|---|---|---|---|---|
| config | Object | ✔️ | AMQP connection configuration. | |
| config.uri | string | The AMQP server connection URI. | ||
| config.amqpOptions | Object | ✔️ | 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();