0
私はtsoaを使用していため闊歩定義を生成し、私は闊歩のAPIのRabbitMQ応答キューオブジェクト
import { configuration, random, uuid, amqp } from '../config';
const EventEmitter = require('events');
const REPLY_QUEUE = 'amq.rabbitmq.reply-to';
const createClient =() => amqp.connect(configuration.amqpUrl)
.then((conn) => conn.createChannel())
.then((channel: any) => {
// create an event emitter where rpc responses will be published by correlationId
channel.responseEmitter = new EventEmitter();
channel.responseEmitter.setMaxListeners(0);
channel.consume(REPLY_QUEUE,
(msg: any) => channel.responseEmitter.emit(msg.properties.correlationId, msg.content),
{ noAck: true });
return channel;
});
const sendRPCMessage = (channel: any, message: any, rpcQueue: any) => new Promise((resolve, reject) => {
const correlationId = uuid.v4();
// listen for the content emitted on the correlationId event
try {
channel.responseEmitter.once(correlationId, resolve);
channel.sendToQueue(rpcQueue, new Buffer(JSON.stringify(message)), { correlationId, replyTo: REPLY_QUEUE })
} catch (error) { reject(error) }
});
のRabbitMQを接続するためのfacundoolano実装を使用していますが、問題は、私はわかりませんでしたのRabbitMQへのAPIリクエストを送信しようとしています要求の応答を返す方法。私のコントローラは、私がどのように正しい方法のRabbitMQの応答キュー