mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
refactor(microservices) use more descriptive channel names
This commit is contained in:
@@ -53,7 +53,7 @@ export class ServerMqtt extends Server implements CustomTransportStrategy {
|
||||
registeredPatterns.forEach(pattern => {
|
||||
const { isEventHandler } = this.messageHandlers.get(pattern);
|
||||
mqttClient.subscribe(
|
||||
isEventHandler ? pattern : this.getAckQueueName(pattern),
|
||||
isEventHandler ? pattern : this.getRequestPattern(pattern),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -110,7 +110,7 @@ export class ServerMqtt extends Server implements CustomTransportStrategy {
|
||||
const outgoingResponse = this.serializer.serialize(response);
|
||||
|
||||
return client.publish(
|
||||
this.getResQueueName(pattern),
|
||||
this.getReplyPattern(pattern),
|
||||
JSON.stringify(outgoingResponse),
|
||||
);
|
||||
};
|
||||
@@ -124,12 +124,12 @@ export class ServerMqtt extends Server implements CustomTransportStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
public getAckQueueName(pattern: string): string {
|
||||
return `${pattern}_ack`;
|
||||
public getRequestPattern(pattern: string): string {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public getResQueueName(pattern: string): string {
|
||||
return `${pattern}_res`;
|
||||
public getReplyPattern(pattern: string): string {
|
||||
return `${pattern}.reply`;
|
||||
}
|
||||
|
||||
public handleError(stream: any) {
|
||||
|
||||
Reference in New Issue
Block a user