You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: daprdocs/content/en/js-sdk-docs/js-server/_index.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -228,6 +228,77 @@ async function start() {
228
228
229
229
> For a full list of state operations visit [How-To: Publish & subscribe]({{< ref howto-publish-subscribe.md >}}).
230
230
231
+
#### Subscribe with SUCCESS/RETRY/DROP status
232
+
233
+
Dapr supports [status codes for retry logic](https://docs.dapr.io/reference/api/pubsub_api/#expected-http-response) to specify what should happen after a message gets processed.
234
+
235
+
> ⚠️ The JS SDK allows multiple callbacks on the same topic, we handle priority of status on `RETRY` > `DROP` > `SUCCESS` and default to `SUCCESS`
236
+
237
+
> ⚠️ Make sure to [configure resiliency](https://docs.dapr.io/operations/resiliency/resiliency-overview/) in your application to handle `RETRY` messages
238
+
239
+
In the JS SDK we support these messages through the `DaprPubSubStatusEnum` enum. To ensure Dapr will retry we configure a Resiliency policy as well.
240
+
241
+
\*\*components/resiliency.yaml`
242
+
243
+
```yaml
244
+
apiVersion: dapr.io/v1alpha1
245
+
kind: Resiliency
246
+
metadata:
247
+
name: myresiliency
248
+
spec:
249
+
policies:
250
+
retries:
251
+
# Global Retry Policy for Inbound Component operations
252
+
DefaultComponentInboundRetryPolicy:
253
+
policy: constant
254
+
duration: 500ms
255
+
maxRetries: 10
256
+
targets:
257
+
components:
258
+
messagebus:
259
+
inbound:
260
+
retry: DefaultComponentInboundRetryPolicy
261
+
```
262
+
263
+
**src/index.ts**
264
+
265
+
```typescript
266
+
import { DaprServer, DaprPubSubStatusEnum } from "@dapr/dapr";
Dapr [supports routing messages](https://docs.dapr.io/developing-applications/building-blocks/pubsub/howto-route-messages/) to different handlers (routes) based on rules.
0 commit comments