Update Multi Pub/Sub How To for consuming topics (#756)

This commit is contained in:
Yaron Schneider 2020-08-19 10:32:35 -07:00 committed by GitHub
parent 94d2fe90eb
commit 9ea913c7d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -51,7 +51,8 @@ const port = 3000
res.json([
{
topic: "newOrder",
route: "orders"
route: "orders",
pubsubName: "messagebus"
}
]);
})</b>
@ -63,6 +64,8 @@ app.post('/orders', (req, res) => {
app.listen(port, () => console.log(`consumer app listening on port ${port}!`))
</pre>
In the payload returned to Dapr, `topic` tells Dapr which topic to subscribe to, `route` tells Dapr which endpoint to call on when a message comes to that topic, and `pubsubName` tells Dapr which pub/sub component it should use. In this example this is `messagebus` as this is the name of the component we outlined above.
## Consume messages
To consume messages from a topic, start a web server in the programming language of your choice and listen on a `POST` endpoint with the route path you specified when subscribing.
@ -74,7 +77,8 @@ app.get('/dapr/subscribe', (req, res) => {
res.json([
{
topic: "onCreated",
route: "custom/path"
route: "custom/path",
pubsubName: "messagebus"
}
]);
})