Skip to content

Commit

Permalink
docs(microservices): clarify hybrid application startup
Browse files Browse the repository at this point in the history
added a note to the microservices section and hybrid application for how to deal
with an application with multiple microservices but no HTTP server
  • Loading branch information
jtimmons committed Sep 7, 2023
1 parent 4c648e3 commit 19d9b92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion content/faq/hybrid-application.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Hybrid application

A hybrid application is one that both listens for HTTP requests, as well as makes use of connected microservices. The `INestApplication` instance can be connected with `INestMicroservice` instances through the `connectMicroservice()` method.
A hybrid application is one that listens for requests from two or more different sources. This can combine an HTTP server with a microservice listener or even just multiple different microservice listeners. The default `createMicroservice` method does not allow for multiple servers so in this case each microservice must be created and started manually. In order to do this, the `INestApplication` instance can be connected with `INestMicroservice` instances through the `connectMicroservice()` method.

```typescript
const app = await NestFactory.create(AppModule);
Expand All @@ -12,6 +12,8 @@ await app.startAllMicroservices();
await app.listen(3001);
```

> info **Hint** the `app.listen(port)` method starts an HTTP server on the specified address. If your application does not handle HTTP requests then you should use the `app.init()` method instead.
To connect multiple microservice instances, issue the call to `connectMicroservice()` for each microservice:

```typescript
Expand Down
2 changes: 2 additions & 0 deletions content/microservices/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ bootstrap();

> info **Hint** Microservices use the **TCP** transport layer by default.
> info **Hint** Multiple microservice listeners can be instantiated within the same NestJS application if needed as well. See the [Hybrid Application](https://docs.nestjs.com/faq/hybrid-application) section for details on how to do so.
The second argument of the `createMicroservice()` method is an `options` object. This object may consist of two members:

<table>
Expand Down

0 comments on commit 19d9b92

Please sign in to comment.