mirror of https://github.com/dapr/docs.git
Update declarative subscriptions (#785)
* Update declarative subscriptions Add more details on how to use in Kubernetes/Self-Hosted. * Update README.md * comments
This commit is contained in:
parent
382f4d5ce4
commit
dbc5667eba
|
@ -38,7 +38,7 @@ Dapr allows two methods by which you can subscribe to topics: programatically, w
|
|||
|
||||
### Declarative subscriptions
|
||||
|
||||
You can subscribe to a topic using the following CRD:
|
||||
You can subscribe to a topic using the following Custom Resources Definition (CRD):
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
|
@ -76,6 +76,27 @@ app.post('/orders', (req, res) => {
|
|||
app.listen(port, () => console.log(`consumer app listening on port ${port}!`))
|
||||
```
|
||||
|
||||
#### Subscribing on Kubernetes
|
||||
|
||||
In Kubernetes, save the CRD to a file and apply it to the cluster:
|
||||
|
||||
```
|
||||
kubectl apply -f subscription.yaml
|
||||
```
|
||||
|
||||
#### Subscribing in Self Hosted
|
||||
|
||||
When running Dapr in Self-hosted, either locally or on a VM, put the CRD in your `./components` directory.
|
||||
When Dapr starts up, it will load subscriptions along with components.
|
||||
|
||||
The following example shows how to point the Dapr CLI to a components path:
|
||||
|
||||
```
|
||||
dapr run --app-id myapp --components-path ./myComponents -- python3 myapp.py
|
||||
```
|
||||
|
||||
*Note: By default, Dapr loads components from $HOME/.dapr/components on MacOS/Linux and %USERPROFILE%\.dapr\components on Windows. If you place the subscription in a custom components path, make sure the Pub/Sub component is present also.*
|
||||
|
||||
### Programmatic subscriptions
|
||||
|
||||
To subscribe to topics, start a web server in the programming language of your choice and listen on the following `GET` endpoint: `/dapr/subscribe`.
|
||||
|
|
Loading…
Reference in New Issue