15 lines
319 B
JavaScript
15 lines
319 B
JavaScript
// rmq.js
|
|
import amqplib from 'amqplib';
|
|
|
|
let channel;
|
|
export async function initRabbit(url) {
|
|
const conn = await amqplib.connect(url);
|
|
channel = await conn.createChannel();
|
|
return channel;
|
|
}
|
|
|
|
export function getChannel() {
|
|
if (!channel) throw new Error('RabbitMQ channel not initialized');
|
|
return channel;
|
|
}
|