diff --git a/content/faq/hybrid-application.md b/content/faq/hybrid-application.md index 2f1ea6ee12..b90cd0b529 100644 --- a/content/faq/hybrid-application.md +++ b/content/faq/hybrid-application.md @@ -35,7 +35,10 @@ await app.startAllMicroservices(); await app.listen(3001); ``` -To bind `@MessagePattern()` to only one transport strategy (for example, MQTT) in a hybrid application with multiple microservices, we can pass the second argument of type `Transport` which is an enum with all the built-in transport strategies defined. +To bind `@MessagePattern()` to only one transport strategy (for example, MQTT) in a hybrid application with multiple microservices, we can pass the second argument with either of below: +1. a `Transport` which is an enum with all the built-in transport strategies defined. +2. a Symbol which is the `transportId` in the Custom Transporter server. + ```typescript @@filename() @@ -48,6 +51,10 @@ getDate(@Payload() data: number[], @Ctx() context: NatsContext) { getTCPDate(@Payload() data: number[]) { return new Date().toLocaleTimeString(...); } +@MessagePattern('topic.time.us', XYZServer.Transport) // suppose we have a custom Transporter XYZ +getXYZDate(@Payload() data: number[]) { + return new Date().toLocaleTimeString(...); +} @@switch @Bind(Payload(), Ctx()) @MessagePattern('time.us.*', Transport.NATS) @@ -60,9 +67,15 @@ getDate(data, context) { getTCPDate(data, context) { return new Date().toLocaleTimeString(...); } + +@Bind(Payload(), Ctx()) +@MessagePattern('topic.time.us', XYZServer.Transport) +getXYZDate(data, context) { + return new Date().toLocaleTimeString(...); +} ``` -> info **Hint** `@Payload()`, `@Ctx()`, `Transport` and `NatsContext` are imported from `@nestjs/microservices`. +> info **Hint** `@Payload()`, `@Ctx()`, `Transport` and `NatsContext` are imported from `@nestjs/microservices`; `XYZServer.Transport` is imported from the Custom Transport, it should be a Symbol that set the `transportId` of `XYZServer`. #### Sharing configuration