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
{{ message }}
Repository navigation
Commit 7f63f90
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: examples/src/main/java/io/dapr/examples/pubsub/README.md
+17-16Lines changed: 17 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -275,13 +275,12 @@ Once running, the Subscriber should print the output as follows:
275
275
276
276
Messages have been retrieved from the topic.
277
277
278
-
### Bulk Publish Messages
279
-
> Note : This API is currently in Alpha stage in Dapr runtime, hence the API methods in SDK are part of the DaprPreviewClient class.
278
+
### Bulk Publish Messages
280
279
281
280
Another feature provided by the SDK is to allow users to publish multiple messages in a single call to the Dapr sidecar.
282
-
For this example, we have a simple Java application with a main method that uses the Dapr gPRC Preview Client to publish 10 messages to a specific topic in a single call.
281
+
For this example, we have a simple Java application with a main method that uses the Dapr Client to publish 10 messages to a specific topic in a single call.
283
282
284
-
In the `BulkPublisher.java` file, you will find the `BulkPublisher` class, containing the main method. The main method declares a Dapr Preview Client using the `DaprClientBuilder` class. Notice that this builder gets two serializer implementations in the constructor: one is for Dapr's sent and recieved objects, and the second is for objects to be persisted.
283
+
In the `BulkPublisher.java` file, you will find the `BulkPublisher` class, containing the main method. The main method declares a Dapr Client using the `DaprClientBuilder` class. Notice that this builder gets two serializer implementations in the constructor: one is for Dapr's sent and recieved objects, and the second is for objects to be persisted.
285
284
The client publishes messages using `publishEvents` method. The Dapr client is also within a try-with-resource block to properly close the client at the end. See the code snippet below:
286
285
Dapr's sidecar will automatically wrap the payload received into a CloudEvent object, which will later on be parsed by the subscriber.
287
286
@@ -296,11 +295,10 @@ public class BulkPublisher {
System.out.println("Constructing the list of messages to publish");
306
304
for (int i =0; i <NUM_MESSAGES; i++) {
@@ -333,7 +331,7 @@ public class BulkPublisher {
333
331
}
334
332
}
335
333
```
336
-
The code uses the `DaprPreviewClient` created by the `DaprClientBuilder` is used for the `publishEvents` (BulkPublish) preview API.
334
+
The code uses the `DaprClient` created by the `DaprClientBuilder` for the `publishEvents` (BulkPublish) API.
337
335
338
336
In this case, when the `publishEvents` call is made, one of the arguments to the method is the content type of data, this being `text/plain` in the example.
339
337
In this case, when parsing and printing the response, there is a concept of EntryID, which is automatically generated or can be set manually when using the `BulkPublishRequest` object.
@@ -350,7 +348,7 @@ In this case, the application **MUST** override the content-type parameter via `
@@ -414,7 +412,7 @@ Once running, the BulkPublisher should print the output as follows:
414
412
```txt
415
413
✅ You're up and running! Both Dapr and your app logs will appear here.
416
414
417
-
== APP == Using preview client...
415
+
== APP == Using Dapr client...
418
416
== APP == Constructing the list of messages to publish
419
417
== APP == Going to publish message : This is message #0
420
418
== APP == Going to publish message : This is message #1
@@ -655,20 +653,23 @@ public class SubscriberGrpcService extends AppCallbackGrpc.AppCallbackImplBase {
655
653
///...
656
654
}
657
655
```
658
-
The `BulkSubscriberGrpcService.java` file is responsible for implementing the processing of bulk message subscriptions. WhenDapr's sidecar successfully subscribes to bulk messages, it will call `onBulkTopicEventAlpha1` and pass them as a request parameter. You can refer to the example on how to handle bulk messages and respond correctly over gPRC.
656
+
657
+
The `SubscriberGrpcService.java` now handles both regular and bulk message subscriptions since bulk pubsub is now stable. WhenDapr's sidecar successfully subscribes to messages, it will call either `onTopicEvent` for regular messages or `onBulkTopicEvent` for bulk messages. Below is an example of the bulk handler:
659
658
660
659
```java
661
-
public class BulkSubscriberGrpcService extends AppCallbackAlphaGrpc.AppCallbackAlphaImplBase {
660
+
public class SubscriberGrpcService extends AppCallbackGrpc.AppCallbackImplBase {
661
+
// ... onTopicEvent method shown above ...
662
662
663
663
@Override
664
-
public void onBulkTopicEventAlpha1(io.dapr.v1.DaprAppCallbackProtos.TopicEventBulkRequest request,
664
+
public void onBulkTopicEvent(io.dapr.v1.DaprAppCallbackProtos.TopicEventBulkRequest request,
0 commit comments