mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
fix - [RabbitMQ Microservice] "PRECONDITION_FAILED - reply consumer already set" #3138
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user