fix - [RabbitMQ Microservice] "PRECONDITION_FAILED - reply consumer already set" #3138

This commit is contained in:
Sergey Telpuk
2019-12-09 17:18:02 +03:00
parent cc5c74993c
commit 7b8d6df4f2

View File

@@ -74,6 +74,7 @@ export class ClientRMQ extends ClientProxy {
}
this.client = this.createClient();
this.handleError(this.client);
this.handleDisconnectError(this.client);
const connect$ = this.connect$(this.client);
this.connection = this.mergeDisconnectEvent(this.client, connect$)
@@ -83,11 +84,6 @@ export class ClientRMQ extends ClientProxy {
)
.toPromise();
this.client.on(DISCONNECT_EVENT, (err)=> {
this.close();
this.client = null;
});
return this.connection;
}
@@ -140,6 +136,14 @@ export class ClientRMQ extends ClientProxy {
client.addListener(ERROR_EVENT, (err: any) => this.logger.error(err));
}
public handleDisconnectError(client: any): void {
client.addListener(DISCONNECT_EVENT, (err: any) => {
this.close();
this.client = null;
return this.logger.error(err);
});
}
public handleMessage(
packet: unknown,
callback: (packet: WritePacket) => any,