docs icon indicating copy to clipboard operation
docs copied to clipboard

Subscription Methods: Unclear/missing information

Open alecor191 opened this issue 3 years ago • 0 comments

Describe the issue

The Declarative Subscriptions doc suggests that using the Dapr SDKs requires two steps to be able to subscribe to a Dapr pubsub:

  1. Component file with kind: Subscription
  2. Use SDK in the app to act when receiving messages from pubsub

However, I used both Python SDK as well as JS SDK to subscribe to pubsub and it worked fine without step 1. above (i.e. no Yaml file used).

I think it would be great if the following items could be clarified in the docs:

  • Under what circumstances is the yaml file required? (e.g. I assume that I need it if I want to specify scopes?)

  • How is the route value in the yaml file used when leveraging SDKs. Looking at the referenced doc, neither in JS nor in Python code samples, I see a reference to the route: /checkout route from the Yaml example:

    //Subscribe to a topic
    await server.pubsub.subscribe("pubsub", "orders", async (orderId) => {
        console.log(`Subscriber received: ${JSON.stringify(orderId)}`)
    });
    await server.startServer();
    
    #Subscribe to a topic 
    @app.subscribe(pubsub_name='pubsub', topic='orders')
    def mytopic(event: v1.Event) -> None:
        data = json.loads(event.Data())
        logging.info('Subscriber received: ' + str(data))
    
    app.run(6002)
    

    Further the doc mentions:

    The /checkout endpoint matches the route defined in the subscriptions and this is where Dapr sends all topic messages to

    But I can't see the JS/Python apps reference anything related to /checkout

URL of the docs

https://docs.dapr.io/developing-applications/building-blocks/pubsub/subscription-methods/

Expected content

  • Provide context under what circumstances the yaml file (kind: Subscription) is required.
  • If SDK + Yaml file are used, please explain the role of route setting.

Screenshots

N/A.

alecor191 avatar Aug 20 '22 07:08 alecor191