@@ -31,19 +31,19 @@ For a Maven project, add the following to your `pom.xml` file:
3131 <dependency>
3232 <groupId>io.dapr</groupId>
3333 <artifactId>dapr-sdk</artifactId>
34- <version>1.7.1 </version>
34+ <version>1.8.0 </version>
3535 </dependency>
3636 <!-- Dapr's SDK for Actors (optional). -->
3737 <dependency>
3838 <groupId>io.dapr</groupId>
3939 <artifactId>dapr-sdk-actors</artifactId>
40- <version>1.7.1 </version>
40+ <version>1.8.0 </version>
4141 </dependency>
4242 <!-- Dapr's SDK integration with SpringBoot (optional). -->
4343 <dependency>
4444 <groupId>io.dapr</groupId>
4545 <artifactId>dapr-sdk-springboot</artifactId>
46- <version>1.7.1 </version>
46+ <version>1.8.0 </version>
4747 </dependency>
4848 ...
4949 </dependencies>
@@ -57,11 +57,11 @@ For a Gradle project, add the following to your `build.gradle` file:
5757dependencies {
5858...
5959 // 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 ')
6161 // 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 ')
6363 // 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 ')
6565}
6666```
6767
@@ -72,7 +72,7 @@ You can fix this by specifying a compatible OkHttp version in your project to ma
7272<dependency>
7373 <groupId>com.squareup.okhttp3</groupId>
7474 <artifactId>okhttp</artifactId>
75- <version>1.7.1 </version>
75+ <version>1.8.0 </version>
7676</dependency>
7777```
7878
@@ -148,7 +148,13 @@ try (DaprClient client = (new DaprClientBuilder()).build()) {
148148```java
149149import com.fasterxml.jackson.databind.ObjectMapper;
150150import 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;
151156import io.dapr.client.domain.CloudEvent;
157+ import io.dapr.springboot.annotations.BulkSubscribe;
152158import org.springframework.web.bind.annotation.PostMapping;
153159import org.springframework.web.bind.annotation.RequestBody;
154160import org.springframework.web.bind.annotation.RestController;
@@ -186,6 +192,62 @@ public class SubscriberController {
186192 });
187193 }
188194
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+ }
189251}
190252```
191253
@@ -292,13 +354,16 @@ try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient())
292354 // Get configuration for a single key
293355 Mono<ConfigurationItem> item = client.getConfiguration(CONFIG_STORE_NAME, CONFIG_KEY).block();
294356
295- // Get Configurations for multiple keys
296- Mono<List< ConfigurationItem>> items =
357+ // Get configurations for multiple keys
358+ Mono<Map<String, ConfigurationItem>> items =
297359 client.getConfiguration(CONFIG_STORE_NAME, CONFIG_KEY_1, CONFIG_KEY_2);
298360
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);
301363 outFlux.subscribe(configItems -> configItems.forEach(...));
364+
365+ // Unsubscribe from configuration changes
366+ Mono<UnsubscribeConfigurationResponse> unsubscribe = client.unsubscribeConfiguration(SUBSCRIPTION_ID, CONFIG_STORE_NAME)
302367}
303368```
304369
0 commit comments