Skip to content

Commit

Permalink
fix: rabbitmq parameter error (#1002)
Browse files Browse the repository at this point in the history
Co-authored-by: 陈河兵 <hebing.chb@alibaba-inc.com>
Co-authored-by: obtenir <1025263994@qq.com>
Co-authored-by: 金炳 <1520006273@qq.com>
Co-authored-by: Harry Chen <czy88840616@gmail.com>
  • Loading branch information
5 people authored Apr 21, 2021
1 parent 132bdbb commit cdbd5f9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/rabbitmq/src/mq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import * as amqp from 'amqplib';
import {
IMidwayRabbitMQConfigurationOptions,
IRabbitMQApplication,
IRabbitMQExchange,
} from './interface';
import { RabbitMQListenerOptions } from '@midwayjs/decorator';
import { ConsumeMessage, Replies } from 'amqplib/properties';
import { ConsumeMessage } from 'amqplib/properties';

export class RabbitMQServer
extends EventEmitter
Expand All @@ -18,12 +19,13 @@ export class RabbitMQServer
private connection: amqp.Connection;
private channel: amqp.Channel;
private reconnectTime: number;
private exchanges: { [exchangeName: string]: Replies.AssertExchange };
private exchanges: IRabbitMQExchange[];

constructor(options: Partial<IMidwayRabbitMQConfigurationOptions>) {
super();
this.options = options;
this.reconnectTime = options.reconnectTime;
this.exchanges = options.exchanges || [];
}

async connect() {
Expand Down Expand Up @@ -109,14 +111,14 @@ export class RabbitMQServer
}

async createBinding(queue, exchange) {
await this.assertQueue(queue.name, queue.options);
await this.assertQueue(queue.queueName, queue.options);
if (!queue.keys) {
await this.bindQueue(queue.name, exchange.name);
await this.bindQueue(queue.queueName, exchange.exchange);
return;
}
for (const index in queue.keys) {
const key = queue.keys[index];
await this.bindQueue(queue.name, exchange.name, key);
await this.bindQueue(queue.queueName, exchange.exchange, key);
}
}

Expand Down

0 comments on commit cdbd5f9

Please sign in to comment.