Skip to content

Commit ac5c9bc

Browse files
authored
Merge branch 'v1.14' into maintainer-comment-actions
2 parents 4c830b0 + 506dff8 commit ac5c9bc

File tree

3 files changed

+48
-46
lines changed

3 files changed

+48
-46
lines changed

daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-bulk.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,13 @@ Status | Description
336336
`RETRY` | Message to be retried by Dapr
337337
`DROP` | Warning is logged and message is dropped
338338

339-
Please refer [Expected HTTP Response for Bulk Subscribe]({{< ref pubsub_api.md >}}) for further insights on response.
339+
Refer to [Expected HTTP Response for Bulk Subscribe]({{< ref pubsub_api.md >}}) for further insights on response.
340340

341341
### Example
342342

343-
Please refer following code samples for how to use Bulk Subscribe:
344-
345-
{{< tabs "Java" "JavaScript" ".NET" >}}
343+
The following code examples demonstrate how to use Bulk Subscribe.
346344

345+
{{< tabs "Java" "JavaScript" ".NET" "Python" >}}
347346
{{% codetab %}}
348347

349348
```java
@@ -471,7 +470,50 @@ public class BulkMessageController : ControllerBase
471470

472471
{{% /codetab %}}
473472

473+
{{% codetab %}}
474+
Currently, you can only bulk subscribe in Python using an HTTP client.
475+
476+
```python
477+
import json
478+
from flask import Flask, request, jsonify
479+
480+
app = Flask(__name__)
481+
482+
@app.route('/dapr/subscribe', methods=['GET'])
483+
def subscribe():
484+
# Define the bulk subscribe configuration
485+
subscriptions = [{
486+
"pubsubname": "pubsub",
487+
"topic": "TOPIC_A",
488+
"route": "/checkout",
489+
"bulkSubscribe": {
490+
"enabled": True,
491+
"maxMessagesCount": 3,
492+
"maxAwaitDurationMs": 40
493+
}
494+
}]
495+
print('Dapr pub/sub is subscribed to: ' + json.dumps(subscriptions))
496+
return jsonify(subscriptions)
497+
498+
499+
# Define the endpoint to handle incoming messages
500+
@app.route('/checkout', methods=['POST'])
501+
def checkout():
502+
messages = request.json
503+
print(messages)
504+
for message in messages:
505+
print(f"Received message: {message}")
506+
return json.dumps({'success': True}), 200, {'ContentType': 'application/json'}
507+
508+
if __name__ == '__main__':
509+
app.run(port=5000)
510+
511+
```
512+
513+
{{% /codetab %}}
514+
474515
{{< /tabs >}}
516+
475517
## How components handle publishing and subscribing to bulk messages
476518

477519
For event publish/subscribe, two kinds of network transfers are involved.

daprdocs/content/en/developing-applications/building-blocks/pubsub/subscription-methods.md

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -203,47 +203,7 @@ As messages are sent to the given message handler code, there is no concept of r
203203

204204
The example below shows the different ways to stream subscribe to a topic.
205205

206-
{{< tabs ".NET" Go>}}
207-
208-
{{% codetab %}}
209-
210-
```csharp
211-
using Dapr.Messaging.PublishSubscribe;
212-
213-
var clientBuilder = new DaprPublishSubscribeClientBuilder();
214-
var daprMessagingClient = clientBuilder.Build();
215-
216-
async Task<TopicResponseAction> HandleMessage(TopicMessage message, CancellationToken cancellationToken = default)
217-
{
218-
try
219-
{
220-
//Do something with the message
221-
Console.WriteLine(Encoding.UTF8.GetString(message.Data.Span));
222-
223-
return await Task.FromResult(TopicResponseAction.Success);
224-
}
225-
catch
226-
{
227-
return await Task.FromResult(TopicResponseAction.Retry);
228-
}
229-
}
230-
231-
//Create a dynamic streaming subscription
232-
var subscription = daprMessagingClient.Register("pubsub", "myTopic",
233-
new DaprSubscriptionOptions(new MessageHandlingPolicy(TimeSpan.FromSeconds(15), TopicResponseAction.Retry)),
234-
HandleMessage, CancellationToken.None);
235-
236-
//Subscribe to messages on it with a timeout of 30 seconds
237-
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
238-
await subscription.SubscribeAsync(cancellationTokenSource.Token);
239-
240-
await Task.Delay(TimeSpan.FromMinutes(1));
241-
242-
//When you're done with the subscription, simply dispose of it
243-
await subscription.DisposeAsync();
244-
```
245-
246-
{{% /codetab %}}
206+
{{< tabs Go>}}
247207

248208
{{% codetab %}}
249209

daprdocs/content/en/operations/observability/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ weight: 60
66
description: See and measure the message calls to components and between networked services
77
---
88

9-
[The following overview video and demo](https://www.youtube.com/live/0y7ne6teHT4?si=3bmNSSyIEIVSF-Ej&t=9931) demonstrates how observability in Dapr works.
9+
[The following overview video and demo](https://www.youtube.com/watch?v=0y7ne6teHT4&t=12652s) demonstrates how observability in Dapr works.
1010

1111
<iframe width="560" height="315" src="https://www.youtube.com/embed/0y7ne6teHT4?si=iURnLk57t2zN-7zP&amp;start=12653" title="YouTube video player" style="padding-bottom:25px;" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
1212

0 commit comments

Comments
 (0)