Building Server APIs Using gRPC for a Java Application
Sometime back I blogged about core projects under the Cloud Native Computing Foundation: https://www.jobinesh.com/2020/01/a-glance-at-cloud-native-computing.html. It is time for us to revisit some of the core projects in detail to learn how to fit them in a real life cloud native application. In this post I will briefly touch one of the promising projects incubating under Cloud Native Computing Foundation: gRPC
What is gRPC ?
The gRPC is remote procedure call (RPC) framework and toolset developed at Google. This is built on top of HTTP/2, leveraging the the benefits of a platform independence of the HTTP. It essentially means that this protocol works with various programming languages :)
Here is the definition from wikipedia:
gRPC (gRPC Remote Procedure Calls) is an open source remote procedure call (RPC) system initially developed at Google in 2015. It uses HTTP/2 for transport, Protocol Buffers as the interface description language, and provides features such as authentication, bidirectional streaming and flow control, blocking or nonblocking bindings, and cancellation and timeouts. It generates cross-platform client and server bindings for many languages.
How gRPC Works?
Like any other communication protocol, in gRPC you define business services containing methods with input parameters and return types. These services are declared using protocol buffers (which is an Interface Definition Language). Physically this is simple text file with .proto extension. You can use protocol buffer compiler tool to generate data access classes as well as client stub (to call gRPC APIs) in your preferred language(s) from the proto definition.
There are four types of methods for a service in gRPC.
You can learn more about this protocol from the official doc: https://grpc.io/docs/guides/concepts/
A Simple Example Illustrating the Usage of gRPC in a Java Application
The following git repository has simple example for using gRPC with Java: https://github.com/jobinesh/cloud-native-applications.git
Stay tuned. We will revisit this topic in coming days with more real life examples and many tools around this stack to keep your life simple :)
What is gRPC ?
The gRPC is remote procedure call (RPC) framework and toolset developed at Google. This is built on top of HTTP/2, leveraging the the benefits of a platform independence of the HTTP. It essentially means that this protocol works with various programming languages :)
Here is the definition from wikipedia:
gRPC (gRPC Remote Procedure Calls) is an open source remote procedure call (RPC) system initially developed at Google in 2015. It uses HTTP/2 for transport, Protocol Buffers as the interface description language, and provides features such as authentication, bidirectional streaming and flow control, blocking or nonblocking bindings, and cancellation and timeouts. It generates cross-platform client and server bindings for many languages.
How gRPC Works?
Like any other communication protocol, in gRPC you define business services containing methods with input parameters and return types. These services are declared using protocol buffers (which is an Interface Definition Language). Physically this is simple text file with .proto extension. You can use protocol buffer compiler tool to generate data access classes as well as client stub (to call gRPC APIs) in your preferred language(s) from the proto definition.
There are four types of methods for a service in gRPC.
- Unary RPC: Client sends single request to server and server responds with a single response
- Server Streaming: Client sends single request to server and server responds with a stream of data
- Client Streaming: Client sends stream of data as part of request. Server waits till client finishes streaming and then responds back with single response
- Bidirectional Streaming: Client sends stream of data as part fo the request and server responds back with stream of data. In this case server can either wait till client finishes the streaming or responds immediately when client initiates the call. Here the two streams operate independently, so that client and server can operate in any order.
You can learn more about this protocol from the official doc: https://grpc.io/docs/guides/concepts/
A Simple Example Illustrating the Usage of gRPC in a Java Application
The following git repository has simple example for using gRPC with Java: https://github.com/jobinesh/cloud-native-applications.git
- You can clone the git repository and navigate to grpc-hello-world-server folder to see the example
- The README.md that you will find in grpc-hello-world-server project has detailed instructions for building the simple gRPC server and client
Stay tuned. We will revisit this topic in coming days with more real life examples and many tools around this stack to keep your life simple :)
This article is a creative one and the concept is good to enhance our knowledge. Waiting for more updates.
ReplyDeleteselenium training in velachery
selenium training in tambaram
java training in tambaram
SEO Training in Anna Nagar
Software Testing Training in T Nagar
Python training in chennai
Android Training in OMR
Software testing training in Anna Nagar
RPA Training in T nagar
Web Designing Course in T Nagar
Nice blog and valuable for all people. Thank you for posting this.
ReplyDeleteJapanese Classes in Chennai
Japanese Course in Chennai
french courses in chennai
pearson vue
Blockchain Training in Chennai
spoken english centre in chennai
Ionic Training in Chennai
best ielts coaching centre in chennai
spanish courses in chennai
content writing course in chennai
Japanese Classes in VelaChery
Japanese Classes in Tambaram
Great Post with valuable information.I am glad that I have visited this site.Share more updates.
ReplyDeleteselenium training in OMR
selenium training in anna nagar
Java Training in OMR
Java course in Tambaram
DevOps Training in Anna Nagar
Digital Marketing Course in Anna Nagar
Software Testing Training in T Nagar
Graphic design courses in Porur
Web Designing Course in T Nagar
PHP Training in Chennai
Thanks for sharing a piece of valuable information.
ReplyDeleteSpark Training Institute in Chennai
Placement Training in Chennai
Soft Skills Training in Chennai
JMeter Training in Chennai
Appium Course Chennai
Advanced Excel Training in Chennai
Excellent blog! Thanks for sharing a very interesting blog, I appreciate your blog post.
ReplyDeleteeasy way to learn java
mobile app development platforms
best campaigns
what is cloud computing azure
tableau interview questions pdf