-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/maven/sdk-tests/com.jayway.json…
…path-json-path-2.9.0
- Loading branch information
Showing
11 changed files
with
445 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
473 changes: 308 additions & 165 deletions
473
examples/src/main/java/io/dapr/examples/pubsub/README.md
Large diffs are not rendered by default.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
examples/src/main/java/io/dapr/examples/pubsub/grpc/BulkSubscriberGrpcService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2023 The Dapr Authors | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package io.dapr.examples.pubsub.grpc; | ||
|
||
import io.dapr.v1.AppCallbackAlphaGrpc; | ||
import io.dapr.v1.DaprAppCallbackProtos.TopicEventBulkRequestEntry; | ||
import io.dapr.v1.DaprAppCallbackProtos.TopicEventBulkResponse; | ||
import io.dapr.v1.DaprAppCallbackProtos.TopicEventBulkResponseEntry; | ||
import io.dapr.v1.DaprAppCallbackProtos.TopicEventResponse.TopicEventResponseStatus; | ||
|
||
/** | ||
* Class that encapsulates all client-side logic for Grpc. | ||
*/ | ||
public class BulkSubscriberGrpcService extends AppCallbackAlphaGrpc.AppCallbackAlphaImplBase { | ||
|
||
@Override | ||
public void onBulkTopicEventAlpha1(io.dapr.v1.DaprAppCallbackProtos.TopicEventBulkRequest request, | ||
io.grpc.stub.StreamObserver<io.dapr.v1.DaprAppCallbackProtos.TopicEventBulkResponse> responseObserver) { | ||
try { | ||
TopicEventBulkResponse.Builder responseBuilder = TopicEventBulkResponse.newBuilder(); | ||
|
||
if (request.getEntriesCount() == 0) { | ||
responseObserver.onNext(responseBuilder.build()); | ||
responseObserver.onCompleted(); | ||
} | ||
|
||
System.out.println("Bulk Subscriber received " + request.getEntriesCount() + " messages."); | ||
|
||
for (TopicEventBulkRequestEntry entry : request.getEntriesList()) { | ||
try { | ||
System.out.printf("Bulk Subscriber message has entry ID: %s\n", entry.getEntryId()); | ||
System.out.printf("Bulk Subscriber got: %s\n", entry.getCloudEvent().getData().toStringUtf8()); | ||
TopicEventBulkResponseEntry.Builder responseEntryBuilder = TopicEventBulkResponseEntry | ||
.newBuilder() | ||
.setEntryId(entry.getEntryId()) | ||
.setStatusValue(TopicEventResponseStatus.SUCCESS_VALUE); | ||
responseBuilder.addStatuses(responseEntryBuilder); | ||
} catch (Throwable e) { | ||
TopicEventBulkResponseEntry.Builder responseEntryBuilder = TopicEventBulkResponseEntry | ||
.newBuilder() | ||
.setEntryId(entry.getEntryId()) | ||
.setStatusValue(TopicEventResponseStatus.RETRY_VALUE); | ||
responseBuilder.addStatuses(responseEntryBuilder); | ||
} | ||
} | ||
TopicEventBulkResponse response = responseBuilder.build(); | ||
responseObserver.onNext(response); | ||
responseObserver.onCompleted(); | ||
} catch (Throwable e) { | ||
responseObserver.onError(e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters