From 05b86c879917e34cd8a480fad80bc6ea2b835bab Mon Sep 17 00:00:00 2001 From: Deepanshu Agarwal Date: Thu, 9 Feb 2023 21:47:30 +0530 Subject: [PATCH] Incorporate review comments Signed-off-by: Deepanshu Agarwal --- .../building-blocks/pubsub/pubsub-bulk.md | 35 ++++++++++++++----- .../content/en/reference/api/pubsub_api.md | 2 +- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-bulk.md b/daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-bulk.md index a958a460a..41ce38259 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-bulk.md +++ b/daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-bulk.md @@ -274,8 +274,8 @@ Invoke-RestMethod -Method Post -ContentType 'application/json' -Uri 'http://loca The bulk subscribe API allows you to subscribe multiple messages from a topic in a single request. As we know from [How to: Publish & Subscribe to topics]({{< ref howto-publish-subscribe.md >}}), there are two ways to subscribe to topic(s): -- **Declaratively**, where subscriptions are defined in an external file. -- **Programmatically**, where subscriptions are defined in user code. +- **Declaratively** - subscriptions are defined in an external file. +- **Programmatically** - subscriptions are defined in code. To Bulk Subscribe to topic(s), we just need to use `bulkSubscribe` spec attribute, something like following: @@ -298,14 +298,29 @@ scopes: - checkout ``` -In the example above, `bulkSubscribe` altogether is _optional_. If you decide to use `bulkSubscribe`, then: -- `enabled` is mandatory -- You can optionally configure the max number of messages (`maxMessagesCount`) delivered via Dapr in a bulk message -- You can optionally provide the max duration to wait (`maxAwaitDurationMs`) before a bulk message is sent via Dapr to the app +In the example above, `bulkSubscribe` is _optional_. If you use `bulkSubscribe`, then: +- `enabled` is mandatory and enables or disables bulk subscriptions on this topic +- You can optionally configure the max number of messages (`maxMessagesCount`) delivered in a bulk message. +Default value of `maxMessagesCount` for components not supporting bulk subscribe is 100 i.e. for default bulk events between App and Dapr. Please refer [How components handle publishing and subscribing to bulk messages]({{< ref pubsub-bulk >}}). +If a component supports bulk subscribe, then default value for this parameter can be found in that component doc. Please refer [Supported components]({{< ref pubsub-bulk >}}). +- You can optionally provide the max duration to wait (`maxAwaitDurationMs`) before a bulk message is sent to the app. +Default value of `maxAwaitDurationMs` for components not supporting bulk subscribe is 1000 i.e. for default bulk events between App and Dapr. Please refer [How components handle publishing and subscribing to bulk messages]({{< ref pubsub-bulk >}}). +If a component supports bulk subscribe, then default value for this parameter can be found in that component doc. Please refer [Supported components]({{< ref pubsub-bulk >}}). -If the application decides not to configure `maxMessagesCount` and/or `maxAwaitDurationMs`, the defaults will be used as per the respective component in Dapr. +The application receives an `EntryId` associated with each entry (individual message) in the bulk message. This `EntryId` must be used by the app to communicate the status of that particular entry. If the app fails to notify on an `EntryId` status, it's considered a `RETRY`. -The application receives an EntryId associated with each entry (individual message) in the bulk message. This EntryId must be used by the app to communicate the status of that particular entry. If the app fails to notify on an EntryId status, it's considered a `RETRY`. +A JSON-encoded payload body with the processing status against each entry needs to be sent: + +```json +{ + "statuses": { + "entryId": "", + "status": "" + } +} +``` + +Possible status values: Status | Description --------- | ----------- @@ -313,8 +328,12 @@ Status | Description `RETRY` | Message to be retried by Dapr `DROP` | Warning is logged and message is dropped +Please refer [Expected HTTP Response for Bulk Subscribe]({{< ref pubsub_api.md >}}) for further insights on response. + ### Example +Please refer following code samples for how to use Bulk Subscribe: + {{< tabs Java Javascript "HTTP API (Bash)" "HTTP API (PowerShell)" >}} {{% codetab %}} diff --git a/daprdocs/content/en/reference/api/pubsub_api.md b/daprdocs/content/en/reference/api/pubsub_api.md index 6bb1675da..a421e89a5 100644 --- a/daprdocs/content/en/reference/api/pubsub_api.md +++ b/daprdocs/content/en/reference/api/pubsub_api.md @@ -247,7 +247,7 @@ other | warning is logged and message to be retried ## Subscribe multiple messages from a given topic -This allows you to subscribe multiple messages from a broker to listen to a `topic`. +This allows you to subscribe to multiple messages from a broker when listening to a `topic`. In order to receive messages in a bulk manner for a topic subscription, the application: