Skip to content

kouky/grpc-java-bazel-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gRPC Java Bazel Examples

This repository includes examples of gRPC Java applications built with Bazel. It's meant as a supplement to the official gRPC Java quick start guide and tutorial.

Before you begin

Clone this repo

git clone git@github.com:kouky/grpc-java-bazel-example.git
cd grpc-java-bazel-example

Run Hello World gRPC Application

Compile all the bazel targets

bazel build //...

Run the server

bazel-bin/src/main/java/org/kouky/helloworld/server/helloworld_server

In another terminal, run the client

bazel-bin/src/main/java/org/kouky/helloworld/client/helloworld_client

You should see the following output as the client talks to the server.

Aug 26, 2018 9:39:49 PM org.kouky.helloworld.client.HelloWorldClient greet
INFO: Will try to greet world ...
Aug 26, 2018 9:39:49 PM org.kouky.helloworld.client.HelloWorldClient greet
INFO: Greeting: Hello world
Aug 26, 2018 9:39:49 PM org.kouky.helloworld.client.HelloWorldClient greet
INFO: Greeting: Hello again world

Run RouteGuide gRPC Application

Compile all the bazel targets

bazel build //...

Run the server

bazel-bin/src/main/java/org/kouky/routeguide/server/routeguide_server

In another terminal, run the client

bazel-bin/src/main/java/org/kouky/routeguide/client/routeguide_client

You should see the following output as the client talks to the server.

Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
INFO: *** GetFeature: lat=409,146,138 lon=-746,188,906
Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
INFO: Found feature called "Berkshire Valley Management Area Trail, Jefferson, NJ, USA" at 40.915, -74.619
Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
INFO: *** GetFeature: lat=0 lon=0
Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
INFO: Found no feature at 0, 0
Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
INFO: *** ListFeatures: lowLat=400,000,000 lowLon=-750,000,000 hiLat=420,000,000 hiLon=-730,000,000
Aug 30, 2018 9:37:52 PM org.kouky.routeguide.client.RouteGuideClient info
INFO: Result #1: name: "Patriots Path, Mendham, NJ 07945, USA"
location {
  latitude: 407838351
  longitude: -746143763
}

3rdParty Dependencies

Third party dependencies are specified in dependencies.yaml and generated by bazel-deps.

To regenerate 3rdparty dependencies clone the bazel-deps repo, change directory into it, and run the following.

bazel run //:parse -- generate -r /path/to/grpc-java-bazel-example -s 3rdparty/workspace.bzl -d dependencies.yaml