Bael 5121 error handling (#11281)

* Commit source code to branch

* BAEL-5065 improvement of groupBy with complex key

* Fixed indentation
This commit is contained in:
mbarriola 2021-10-03 22:57:34 -04:00 committed by GitHub
parent b57f3c22ba
commit 6781cea471

View File

@ -29,47 +29,47 @@ public class CommodityClient {
nonBlockingStub = CommodityPriceProviderGrpc.newStub(channel); nonBlockingStub = CommodityPriceProviderGrpc.newStub(channel);
} }
public void getBidirectionalCommodityPriceLists() throws InterruptedException { public void getBidirectionalCommodityPriceLists() throws InterruptedException {
logger.info("#######START EXAMPLE#######: BidirectionalStreaming - getCommodityPriceLists from list of commodities"); logger.info("#######START EXAMPLE#######: BidirectionalStreaming - getCommodityPriceLists from list of commodities");
final CountDownLatch finishLatch = new CountDownLatch(1); final CountDownLatch finishLatch = new CountDownLatch(1);
StreamObserver<StreamingCommodityQuote> responseObserver = new StreamObserver<StreamingCommodityQuote>() { StreamObserver<StreamingCommodityQuote> responseObserver = new StreamObserver<StreamingCommodityQuote>() {
@Override @Override
public void onNext(StreamingCommodityQuote streamingCommodityQuote) { public void onNext(StreamingCommodityQuote streamingCommodityQuote) {
switch (streamingCommodityQuote.getMessageCase()) { switch (streamingCommodityQuote.getMessageCase()) {
case COMODITY_QUOTE: case COMODITY_QUOTE:
CommodityQuote commodityQuote = streamingCommodityQuote.getComodityQuote(); CommodityQuote commodityQuote = streamingCommodityQuote.getComodityQuote();
logger.info("RESPONSE producer:" + commodityQuote.getCommodityName() + " price:" + commodityQuote.getPrice()); logger.info("RESPONSE producer:" + commodityQuote.getCommodityName() + " price:" + commodityQuote.getPrice());
break; break;
case STATUS: case STATUS:
com.google.rpc.Status status = streamingCommodityQuote.getStatus(); com.google.rpc.Status status = streamingCommodityQuote.getStatus();
logger.info("RESPONSE status error:"); logger.info("RESPONSE status error:");
logger.info("Status code:" + Code.forNumber(status.getCode())); logger.info("Status code:" + Code.forNumber(status.getCode()));
logger.info("Status message:" + status.getMessage()); logger.info("Status message:" + status.getMessage());
for (Any any : status.getDetailsList()) { for (Any any : status.getDetailsList()) {
if (any.is(ErrorInfo.class)) { if (any.is(ErrorInfo.class)) {
ErrorInfo errorInfo; ErrorInfo errorInfo;
try { try {
errorInfo = any.unpack(ErrorInfo.class); errorInfo = any.unpack(ErrorInfo.class);
logger.info("Reason:" + errorInfo.getReason()); logger.info("Reason:" + errorInfo.getReason());
logger.info("Domain:" + errorInfo.getDomain()); logger.info("Domain:" + errorInfo.getDomain());
logger.info("Insert Token:" + errorInfo.getMetadataMap().get("insertToken")); logger.info("Insert Token:" + errorInfo.getMetadataMap()
} catch (InvalidProtocolBufferException e) { .get("insertToken"));
logger.error(e.getMessage()); } catch (InvalidProtocolBufferException e) {
logger.error(e.getMessage());
}
}
}
break;
default:
logger.info("Unknow message case");
} }
} }
}
break;
default:
logger.info("Unknow message case");
}
}
@Override @Override
public void onCompleted() { public void onCompleted() {
logger.info("Finished getBidirectionalCommodityPriceListss"); logger.info("Finished getBidirectionalCommodityPriceLists");
finishLatch.countDown(); finishLatch.countDown();
} }