Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add Grpc to your Java application

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to add Grpc to your Java application", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to add Grpc to your Java application" this article.

Grpc is a high-performance, open source general RPC framework.

There are several benefits to using gRPC:

It simplifies development by providing client / server code

It supports multiple languages

It all starts with defining a .proto file, and the. proto file is located in the src/main/proto file.

Please note that it is a good practice to save the proto file on repo and do some schema versioning. In this way, developers on other teams can reference them to generate their sdk, even for other languages.

We will create an order service on src/main/proto/Order.proto

Yntax = "proto3"; option java_multiple_files = true;option java_package = "com.egkatzioura.order.v1"; service OrderService {rpc ExecuteOrder (OrderRequest) returns (OrderResponse) {};} message OrderRequest {string email = 1; string product = 2; int32 amount = 3;} message OrderResponse {string info = 1;}

In order to use grpc, you need to place the following related files

Io.grpc grpc-netty-shaded 1.39.0 io.grpc grpc-protobuf 1.39.0 io.grpc grpc-stub 1.39.0 org.apache.tomcat annotations-api 6.0.53 provided

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report