Skip to content

Commit

Permalink
progress with #326
Browse files Browse the repository at this point in the history
  • Loading branch information
jvmlet committed Dec 8, 2022
1 parent c9f80c9 commit 3fc51bc
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.test.context.junit4.SpringRunner;

import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
Expand All @@ -44,11 +45,19 @@ public static class TestConfig {
class MyCustomService extends CustomServiceGrpc.CustomServiceImplBase {
@Override
public void custom(Custom.CustomRequest request, StreamObserver<Custom.CustomReply> responseObserver) {
kafkaTemplate.send(kafkaTemplate.getDefaultTopic(), request.getName().getBytes())
.addCallback(e -> {
responseObserver.onNext(Custom.CustomReply.newBuilder().setMessage(request.getName()).build());
responseObserver.onCompleted();
}, responseObserver::onError);
kafkaTemplate.send(kafkaTemplate.getDefaultTopic(), request.getName().getBytes())
.handle((r, e) -> {
if (null == e) {
responseObserver.onNext(Custom.CustomReply.newBuilder().setMessage(request.getName()).build());
responseObserver.onCompleted();
} else {
responseObserver.onError(e);
}

return true;
}

).join();
}
}

Expand Down

0 comments on commit 3fc51bc

Please sign in to comment.