Hands-on with gRPC with Java & Mongo

We shall be building a Blog application which shall support CRUD features with help of On-Premises MongoDB. So,

Step 1.) Lets begin with installation of MongoDB at our local machine :-

aditya-MAC:bin aditya$ pwd

/Users/aditya/Documents/LEARNING/MongoDB/mongodb-macos-x86_64–4.4.1/bin

aditya-MAC:bin aditya$ ./mongod — dbpath ../data/db

{“t”:{“$date”:”2020–10–18T13:42:27.926+05:30"},”s”:”I”, “c”:”CONTROL”, “id”:23285, “ctx”:”main”,”msg”:”Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify — sslDisabledProtocols ‘none’”}

{“t”:{“$date”:”2020–10–18T13:42:28.867+05:30"},”s”:”I”, “c”:”NETWORK”, “id”:23015, “ctx”:”listener”,”msg”:”Listening on”,”attr”:{“address”:”/tmp/mongodb-27017.sock”}}

{“t”:{“$date”:”2020–10–18T13:42:28.867+05:30"},”s”:”I”, “c”:”NETWORK”, “id”:23015, “ctx”:”listener”,”msg”:”Listening on”,”attr”:{“address”:”127.0.0.1"}}

Part1.) Create Records API :-

Step 1.) Next course of action is to define the service and message structures :-

Step 2.) Next course of action is to define the logic of our service :-

Step 3.) Next, Lets see a basic way to write the servers the gRPC way :-

Step 4.) Next, Lets see a simple implementation for client :-

Part2.) Read Records API :-

Step 1.) Lets define the service and Messages formats :-

Step 2.) Next course of action is to define the logic of our service :-

Step 3.) Next, The server shall remain same as we defined above.

Step 4.) Next, Lets see a how the Client shall look like for this use-case :-

Part3.) Update Records API :-

Step 1.) Lets define the service and Messages formats :-

Step 2.) Next course of action is to define the logic of our service :-

Step 3.) Next, The server shall remain same as we defined above.

Step 4.) Next, Lets see a how the Client shall look like for this use-case :-

Part4.) Delete Records API :-

Step 1.) Lets define the service and Messages formats :-

Step 2.) Next course of action is to define the logic of our service :-

Step 3.) Next, The server shall remain same as we defined above.

Step 4.) Next, Lets see a how the Client shall look like for this use-case :-

Lets now play with these APIs through evans CLI :-

References :-

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store