├── .gitignore
├── .travis.yml
├── README.md
├── eureka-server
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── exampledriven
│ │ │ └── eureka
│ │ │ └── customer
│ │ │ └── server
│ │ │ └── Application.java
│ └── resources
│ │ └── application.yml
│ └── test
│ └── java
│ └── org
│ └── exampledriven
│ └── eureka
│ └── customer
│ └── shared
│ └── ApplicationTests.java
├── jmeter
└── rest-vs-grpc.jmx
├── pom.xml
├── spring-boot-grpc-client-Example2
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── route_guide
│ │ └── RouteGuideClient.java
│ ├── proto
│ └── route_guide.proto
│ └── resources
│ └── application.properties
├── spring-boot-grpc-client
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── org
│ │ └── exampledriven
│ │ ├── SpringBootGrpcClientApplication.java
│ │ ├── grpc
│ │ ├── BookGrpcController.java
│ │ ├── BookServiceGrpcClient.java
│ │ └── TestDataUtil.java
│ │ └── rest
│ │ ├── Book.java
│ │ ├── BookRestController.java
│ │ └── TestDataUtil.java
│ ├── proto
│ └── BookService.proto
│ └── resources
│ └── application.yml
├── spring-boot-grpc-server-Example2
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── route_guide
│ │ ├── RouteGuideServer.java
│ │ ├── RouteGuideService.java
│ │ └── RouteGuideUtil.java
│ ├── proto
│ └── route_guide.proto
│ └── resources
│ └── application.properties
└── spring-boot-grpc-server
├── pom.xml
└── src
├── main
├── java
│ └── org
│ │ └── exampledriven
│ │ ├── BookGrpcService.java
│ │ ├── BookUtil.java
│ │ ├── GrpcExampleApplication.java
│ │ └── rest
│ │ ├── Book.java
│ │ └── BooksRestController.java
├── proto
│ └── BookService.proto
└── resources
│ └── application.yml
└── test
└── java
└── org
└── exampledriven
└── GrpcExampleApplicationTests.java
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | .idea
3 | *.iml
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk: oraclejdk8
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/ExampleDriven/spring-boot-grpc-example)
2 |
3 | ## Overview
4 |
5 | Example project to demostraing spring-boot integration with gRpc. Additonal to a gRpc client and server it has a traditional Spring MVC rest client using very similar payload. The performance of the two technologies can be compared usin the included JMeter file.
6 |
7 | ## Test URLs
8 |
9 | Description | URL
10 | --- | ---
11 | GRPC client test compact output | http://localhost:8080/test_grpc?compact=true
12 | GRPC client test verbose output | http://localhost:8080/test_grpc
13 | REST client test compact output | http://localhost:8080/test_rest/compact
14 | REST client test verbose output | http://localhost:8080/test_rest
15 |
16 | ## How to measure performance
17 | - The jmeter directory contains the jmeter test definition
18 | - use the compact endpoints
19 | - To eliminate "noise" turn off logging by commenting out the appropriate lines in application.yaml both for the server and the client
20 |
21 |
22 | ## Useful resources
23 |
24 | - https://www.youtube.com/watch?v=xpmFhTMqWhc
25 | - http://www.ustream.tv/recorded/86187859
26 | - https://github.com/LogNet/grpc-spring-boot-starter
27 | - http://www.grpc.io/docs/
28 |
--------------------------------------------------------------------------------
/eureka-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | eureka-server
7 | 0.0.1-SNAPSHOT
8 | jar
9 |
10 | Eureka Server
11 | Eureka Server
12 |
13 |
14 | org.springframework.boot
15 | spring-boot-starter-parent
16 | 1.4.1.RELEASE
17 |
18 |
19 |
20 |
21 | org.springframework.cloud
22 | spring-cloud-starter-eureka-server
23 |
24 |
25 | junit
26 | junit
27 | 4.13.1
28 | test
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-starter-test
33 | test
34 |
35 |
36 |
37 |
38 |
39 |
40 | org.springframework.cloud
41 | spring-cloud-dependencies
42 | Camden.RELEASE
43 | pom
44 | import
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-maven-plugin
54 |
55 |
56 | org.apache.maven.plugins
57 | maven-compiler-plugin
58 | 3.3
59 |
60 | 1.8
61 | 1.8
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/eureka-server/src/main/java/org/exampledriven/eureka/customer/server/Application.java:
--------------------------------------------------------------------------------
1 | package org.exampledriven.eureka.customer.server;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
7 |
8 | @SpringBootApplication
9 | @EnableEurekaServer
10 | @EnableDiscoveryClient
11 | public class Application {
12 |
13 | public static void main(String[] args) throws Exception {
14 | SpringApplication.run(Application.class, args);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/eureka-server/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8761
3 |
4 | eureka:
5 | client:
6 | registerWithEureka: false
7 | fetchRegistry: false
8 | server:
9 | enableSelfPreservation: false
--------------------------------------------------------------------------------
/eureka-server/src/test/java/org/exampledriven/eureka/customer/shared/ApplicationTests.java:
--------------------------------------------------------------------------------
1 | package org.exampledriven.eureka.customer.shared;
2 |
3 | import static org.junit.Assert.assertEquals;
4 |
5 | import java.util.Map;
6 |
7 | import org.exampledriven.eureka.customer.server.Application;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.beans.factory.annotation.Value;
12 | import org.springframework.boot.context.embedded.LocalServerPort;
13 | import org.springframework.boot.test.IntegrationTest;
14 | import org.springframework.boot.test.SpringApplicationConfiguration;
15 | import org.springframework.boot.test.web.client.TestRestTemplate;
16 | import org.springframework.boot.test.context.SpringBootTest;
17 | import org.springframework.http.HttpStatus;
18 | import org.springframework.http.ResponseEntity;
19 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
20 | import org.springframework.test.context.web.WebAppConfiguration;
21 |
22 | @RunWith(SpringJUnit4ClassRunner.class)
23 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class)
24 | public class ApplicationTests {
25 |
26 | @Value("${local.server.port}")
27 | private int port = 9999;
28 |
29 | @Test
30 | public void catalogLoads() {
31 | @SuppressWarnings("rawtypes")
32 | ResponseEntity