@@ -31,19 +31,19 @@ For a Maven project, add the following to your `pom.xml` file:
31
31
<dependency>
32
32
<groupId>io.dapr</groupId>
33
33
<artifactId>dapr-sdk</artifactId>
34
- <version>1.7.1 </version>
34
+ <version>1.8.0 </version>
35
35
</dependency>
36
36
<!-- Dapr's SDK for Actors (optional). -->
37
37
<dependency>
38
38
<groupId>io.dapr</groupId>
39
39
<artifactId>dapr-sdk-actors</artifactId>
40
- <version>1.7.1 </version>
40
+ <version>1.8.0 </version>
41
41
</dependency>
42
42
<!-- Dapr's SDK integration with SpringBoot (optional). -->
43
43
<dependency>
44
44
<groupId>io.dapr</groupId>
45
45
<artifactId>dapr-sdk-springboot</artifactId>
46
- <version>1.7.1 </version>
46
+ <version>1.8.0 </version>
47
47
</dependency>
48
48
...
49
49
</dependencies>
@@ -57,11 +57,11 @@ For a Gradle project, add the following to your `build.gradle` file:
57
57
dependencies {
58
58
...
59
59
// Dapr's core SDK with all features, except Actors.
60
- compile('io.dapr:dapr-sdk:1.7.0 ')
60
+ compile('io.dapr:dapr-sdk:1.7.1 ')
61
61
// Dapr's SDK for Actors (optional).
62
- compile('io.dapr:dapr-sdk-actors:1.7.0 ')
62
+ compile('io.dapr:dapr-sdk-actors:1.7.1 ')
63
63
// Dapr's SDK integration with SpringBoot (optional).
64
- compile('io.dapr:dapr-sdk-springboot:1.7.0 ')
64
+ compile('io.dapr:dapr-sdk-springboot:1.7.1 ')
65
65
}
66
66
```
67
67
@@ -72,7 +72,7 @@ You can fix this by specifying a compatible OkHttp version in your project to ma
72
72
<dependency>
73
73
<groupId>com.squareup.okhttp3</groupId>
74
74
<artifactId>okhttp</artifactId>
75
- <version>1.7.1 </version>
75
+ <version>1.8.0 </version>
76
76
</dependency>
77
77
```
78
78
@@ -148,7 +148,13 @@ try (DaprClient client = (new DaprClientBuilder()).build()) {
148
148
```java
149
149
import com.fasterxml.jackson.databind.ObjectMapper;
150
150
import io.dapr.Topic;
151
+ import io.dapr.client.domain.BulkSubscribeAppResponse;
152
+ import io.dapr.client.domain.BulkSubscribeAppResponseEntry;
153
+ import io.dapr.client.domain.BulkSubscribeAppResponseStatus;
154
+ import io.dapr.client.domain.BulkSubscribeMessage;
155
+ import io.dapr.client.domain.BulkSubscribeMessageEntry;
151
156
import io.dapr.client.domain.CloudEvent;
157
+ import io.dapr.springboot.annotations.BulkSubscribe;
152
158
import org.springframework.web.bind.annotation.PostMapping;
153
159
import org.springframework.web.bind.annotation.RequestBody;
154
160
import org.springframework.web.bind.annotation.RestController;
@@ -186,6 +192,62 @@ public class SubscriberController {
186
192
});
187
193
}
188
194
195
+ @BulkSubscribe()
196
+ @Topic(name = "testingtopicbulk", pubsubName = "${myAppProperty:messagebus}")
197
+ @PostMapping(path = "/testingtopicbulk")
198
+ public Mono<BulkSubscribeAppResponse> handleBulkMessage(
199
+ @RequestBody(required = false) BulkSubscribeMessage<CloudEvent<String>> bulkMessage) {
200
+ return Mono.fromCallable(() -> {
201
+ if (bulkMessage.getEntries().size() == 0) {
202
+ return new BulkSubscribeAppResponse(new ArrayList<BulkSubscribeAppResponseEntry>());
203
+ }
204
+
205
+ System.out.println("Bulk Subscriber received " + bulkMessage.getEntries().size() + " messages.");
206
+
207
+ List<BulkSubscribeAppResponseEntry> entries = new ArrayList<BulkSubscribeAppResponseEntry>();
208
+ for (BulkSubscribeMessageEntry<?> entry : bulkMessage.getEntries()) {
209
+ try {
210
+ System.out.printf("Bulk Subscriber message has entry ID: %s\n", entry.getEntryId());
211
+ CloudEvent<?> cloudEvent = (CloudEvent<?>) entry.getEvent();
212
+ System.out.printf("Bulk Subscriber got: %s\n", cloudEvent.getData());
213
+ entries.add(new BulkSubscribeAppResponseEntry(entry.getEntryId(), BulkSubscribeAppResponseStatus.SUCCESS));
214
+ } catch (Exception e) {
215
+ e.printStackTrace();
216
+ entries.add(new BulkSubscribeAppResponseEntry(entry.getEntryId(), BulkSubscribeAppResponseStatus.RETRY));
217
+ }
218
+ }
219
+ return new BulkSubscribeAppResponse(entries);
220
+ });
221
+ }
222
+ }
223
+ ```
224
+
225
+ ##### Bulk Publish Messages
226
+ > Note: API is in Alpha stage
227
+
228
+
229
+ ```java
230
+ import io.dapr.client.DaprClientBuilder;
231
+ import io.dapr.client.DaprPreviewClient;
232
+ import io.dapr.client.domain.BulkPublishResponse;
233
+ import io.dapr.client.domain.BulkPublishResponseFailedEntry;
234
+ import java.util.ArrayList;
235
+ import java.util.List;
236
+ class Solution {
237
+ public void publishMessages() {
238
+ try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient()) {
239
+ // Create a list of messages to publish
240
+ List<String> messages = new ArrayList<>();
241
+ for (int i = 0; i < NUM_MESSAGES; i++) {
242
+ String message = String.format("This is message #%d", i);
243
+ messages.add(message);
244
+ System.out.println("Going to publish message : " + message);
245
+ }
246
+
247
+ // Publish list of messages using the bulk publish API
248
+ BulkPublishResponse<String> res = client.publishEvents(PUBSUB_NAME, TOPIC_NAME, "text/plain", messages).block()
249
+ }
250
+ }
189
251
}
190
252
```
191
253
@@ -292,13 +354,16 @@ try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient())
292
354
// Get configuration for a single key
293
355
Mono<ConfigurationItem> item = client.getConfiguration(CONFIG_STORE_NAME, CONFIG_KEY).block();
294
356
295
- // Get Configurations for multiple keys
296
- Mono<List< ConfigurationItem>> items =
357
+ // Get configurations for multiple keys
358
+ Mono<Map<String, ConfigurationItem>> items =
297
359
client.getConfiguration(CONFIG_STORE_NAME, CONFIG_KEY_1, CONFIG_KEY_2);
298
360
299
- // Susbcribe to Confifuration changes
300
- Flux<List<ConfigurationItem>> outFlux = client.subscribeToConfiguration (CONFIG_STORE_NAME, CONFIG_KEY_1, CONFIG_KEY_2);
361
+ // Subscribe to configuration changes
362
+ Flux<SubscribeConfigurationResponse> outFlux = client.subscribeConfiguration (CONFIG_STORE_NAME, CONFIG_KEY_1, CONFIG_KEY_2);
301
363
outFlux.subscribe(configItems -> configItems.forEach(...));
364
+
365
+ // Unsubscribe from configuration changes
366
+ Mono<UnsubscribeConfigurationResponse> unsubscribe = client.unsubscribeConfiguration(SUBSCRIPTION_ID, CONFIG_STORE_NAME)
302
367
}
303
368
```
304
369
0 commit comments