diff --git a/pom.xml b/pom.xml
index a5f64e5..2f3db2b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,7 @@
chat-javafx-client
metadata-context-example
zipkin-prometheus-example
+ springboot
diff --git a/springboot/eureka-server/src/main/resources/application.properties b/springboot/eureka-server/src/main/resources/application.properties
deleted file mode 100644
index 89272de..0000000
--- a/springboot/eureka-server/src/main/resources/application.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-server.port=8761
-spring.application.name=Eureka Server
-eureka.client.registerWithEureka=false
-eureka.client.fetchRegistry=false
-eureka.client.server.waitTimeInMsWhenSyncEmpty=0
diff --git a/springboot/eureka-server/src/main/resources/application.yml b/springboot/eureka-server/src/main/resources/application.yml
new file mode 100644
index 0000000..7d47295
--- /dev/null
+++ b/springboot/eureka-server/src/main/resources/application.yml
@@ -0,0 +1,17 @@
+server:
+ port: 8761
+spring:
+ application:
+ name: Eureka Server
+
+
+eureka:
+ server:
+ enableSelfPreservation: false
+ instance:
+ leaseRenewalIntervalInSeconds: 3
+ client:
+ registerWithEureka: false
+ fetchRegistry: false
+ server:
+ waitTimeInMsWhenSyncEmpty: 0
diff --git a/springboot/grpc-client/pom.xml b/springboot/grpc-client/pom.xml
index 90845dc..fec2d27 100644
--- a/springboot/grpc-client/pom.xml
+++ b/springboot/grpc-client/pom.xml
@@ -27,7 +27,24 @@
4.0.0
springboot-grpc-client
+
+
+ io.grpc
+ grpc-netty
+ ${grpc.version}
+
+
+ io.grpc
+ grpc-protobuf
+ ${grpc.version}
+
+
+ io.grpc
+ grpc-stub
+ ${grpc.version}
+
+
org.springframework.cloud
spring-cloud-starter-eureka
@@ -42,30 +59,20 @@
-
- ${project.groupId}
- springboot-grpc-server
- ${project.version}
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- com.github.saturnism.springboot
- grpc-server-starter
-
-
-
com.github.saturnism.springboot
grpc-client-starter
1.0.0-SNAPSHOT
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+ org.springframework.cloud
+ spring-cloud-starter-feign
+
@@ -75,5 +82,32 @@
os-maven-plugin
+
+
+
+ org.xolstice.maven.plugins
+ protobuf-maven-plugin
+ ${protoc.plugin.version}
+
+ com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
+ grpc-java
+ io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
+
+
+
+
+ compile
+ compile-custom
+
+
+
+
+
+ kr.motd.maven
+ os-maven-plugin
+ ${os.plugin.version}
+
+
+
diff --git a/springboot/grpc-client/src/main/java/com/example/grpc/springboot/Cmd.java b/springboot/grpc-client/src/main/java/com/example/grpc/springboot/Cmd.java
index 3e55d86..bce8a37 100644
--- a/springboot/grpc-client/src/main/java/com/example/grpc/springboot/Cmd.java
+++ b/springboot/grpc-client/src/main/java/com/example/grpc/springboot/Cmd.java
@@ -20,9 +20,11 @@
import com.example.echo.EchoServiceGrpc;
import io.grpc.Channel;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.ApplicationArguments;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.grpc.client.GrpcChannelFactory;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
@@ -31,23 +33,26 @@
@Component
@EnableDiscoveryClient
public class Cmd {
- @Autowired
- public Cmd(ApplicationArguments args, GrpcChannelFactory channelFactory) {
- System.out.println("hello");
+ private int i = 0;
+ private GrpcChannelFactory channelFactory;
+ private DiscoveryClient discoveryClient;
- Channel channel = channelFactory.createChannel("EchoService");
+ @Autowired
+ public Cmd(@Qualifier("discoveryClientChannelFactory") GrpcChannelFactory channelFactory,
+ DiscoveryClient discoveryClient ) {
+ this.channelFactory = channelFactory;
+ this.discoveryClient = discoveryClient;
+ }
- int i = 0;
- while (true) {
- EchoServiceGrpc.EchoServiceBlockingStub stub = EchoServiceGrpc.newBlockingStub(channel);
- EchoOuterClass.Echo response = stub.echo(EchoOuterClass.Echo.newBuilder().setMessage("Hello " + i).build());
- System.out.println(response);
- i++;
+ @Scheduled(fixedRate = 5000)
+ public void requestRegular() {
+ System.out.println("hello");
+ Channel channel = channelFactory.createChannel("EchoService");
+// discoveryClient.getServices();
- try {
- Thread.sleep(100L);
- } catch (InterruptedException e) {
- }
- }
- }
+ i++;
+ EchoServiceGrpc.EchoServiceBlockingStub stub = EchoServiceGrpc.newBlockingStub(channel);
+ EchoOuterClass.Echo response = stub.echo(EchoOuterClass.Echo.newBuilder().setMessage("Hello " + i).build());
+ System.out.println(response);
+ }
}
diff --git a/springboot/grpc-client/src/main/java/com/example/grpc/springboot/GrpcClient.java b/springboot/grpc-client/src/main/java/com/example/grpc/springboot/GrpcClient.java
index 5f4331c..6177c34 100644
--- a/springboot/grpc-client/src/main/java/com/example/grpc/springboot/GrpcClient.java
+++ b/springboot/grpc-client/src/main/java/com/example/grpc/springboot/GrpcClient.java
@@ -16,18 +16,14 @@
package com.example.grpc.springboot;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
-import org.springframework.stereotype.Component;
/**
* Created by rayt on 5/18/16.
*/
@SpringBootApplication
-@Component
@EnableEurekaClient
public class GrpcClient {
public static void main(String[] args) {
diff --git a/springboot/grpc-client/src/main/proto/Echo.proto b/springboot/grpc-client/src/main/proto/Echo.proto
new file mode 100644
index 0000000..296d058
--- /dev/null
+++ b/springboot/grpc-client/src/main/proto/Echo.proto
@@ -0,0 +1,11 @@
+syntax = "proto3";
+
+package com.example.echo;
+
+message Echo {
+ string message = 1;
+}
+
+service EchoService {
+ rpc echo(Echo) returns (Echo);
+}
diff --git a/springboot/grpc-client/src/main/resources/application.properties b/springboot/grpc-client/src/main/resources/application.properties
index 601fd12..fd1c651 100644
--- a/springboot/grpc-client/src/main/resources/application.properties
+++ b/springboot/grpc-client/src/main/resources/application.properties
@@ -13,7 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
+port=19001
+server.port=19000
spring.application.name=grpc-client
+spring.main.web-environment=false
grpc.client.channels.EchoService.discovery=true
diff --git a/springboot/grpc-client/src/main/resources/logback.xml b/springboot/grpc-client/src/main/resources/logback.xml
new file mode 100644
index 0000000..239f6c2
--- /dev/null
+++ b/springboot/grpc-client/src/main/resources/logback.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+ UTF-8
+ %date{yyyy-MM-dd HH:mm:ss} [%thread] %-5level [%file:%line] - %msg%n
+
+
+
+
+
+
+
+
diff --git a/springboot/grpc-server/pom.xml b/springboot/grpc-server/pom.xml
index f1b2365..b594e45 100644
--- a/springboot/grpc-server/pom.xml
+++ b/springboot/grpc-server/pom.xml
@@ -26,6 +26,22 @@
+
+ io.grpc
+ grpc-netty
+ ${grpc.version}
+
+
+ io.grpc
+ grpc-protobuf
+ ${grpc.version}
+
+
+ io.grpc
+ grpc-stub
+ ${grpc.version}
+
+
org.springframework.boot
spring-boot-starter
diff --git a/springboot/grpc-server/src/main/java/com/example/grpc/springboot/EchoServiceImpl.java b/springboot/grpc-server/src/main/java/com/example/grpc/springboot/EchoServiceImpl.java
index b6829bb..ad5de32 100644
--- a/springboot/grpc-server/src/main/java/com/example/grpc/springboot/EchoServiceImpl.java
+++ b/springboot/grpc-server/src/main/java/com/example/grpc/springboot/EchoServiceImpl.java
@@ -25,10 +25,11 @@
* Created by rayt on 5/18/16.
*/
@GrpcService(EchoServiceGrpc.class)
-public class EchoServiceImpl implements EchoServiceGrpc.EchoService {
+public class EchoServiceImpl extends EchoServiceGrpc.EchoServiceImplBase {
+
@Override
public void echo(EchoOuterClass.Echo request, StreamObserver responseObserver) {
- System.out.println(request);
+ System.out.println("####################" + request + " port ");
responseObserver.onNext(request);
responseObserver.onCompleted();
}
diff --git a/springboot/grpc-server/src/main/resources/application.properties b/springboot/grpc-server/src/main/resources/application.properties
deleted file mode 100644
index 5775383..0000000
--- a/springboot/grpc-server/src/main/resources/application.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-grpc.server.port=${server.port:9090}
-spring.application.name=EchoService
-eureka.instance.nonSecurePort=${server.port}
diff --git a/springboot/grpc-server/src/main/resources/application.yml b/springboot/grpc-server/src/main/resources/application.yml
new file mode 100644
index 0000000..0a2c798
--- /dev/null
+++ b/springboot/grpc-server/src/main/resources/application.yml
@@ -0,0 +1,19 @@
+port: 9004
+grpc:
+ server:
+ port: ${port}
+spring:
+ application:
+ name: EchoService
+server:
+ port: ${port}
+#eureka.instance.instanceId=instance-2
+#eureka.instance.nonSecurePort=${server.port:9091}
+#eureka.instance.nonSecurePort=${server.port}
+
+
+eureka:
+ instance:
+ nonSecurePort: ${port}
+ leaseRenewalIntervalInSeconds: 1
+ leaseExpirationDurationInSeconds: 2
diff --git a/springboot/pom.xml b/springboot/pom.xml
index 9fc6c33..b0b5e10 100644
--- a/springboot/pom.xml
+++ b/springboot/pom.xml
@@ -2,20 +2,25 @@
-
- grpc-demos
- com.example
- 1.0-SNAPSHOT
- ..
-
+
4.0.0
+ com.example
springboot
+ 1.0-SNAPSHOT
pom
- 1.3.5.RELEASE
- Brixton.RELEASE
+ 1.5.2.RELEASE
+ Dalston.RELEASE
+ 1.0.0
+ 3.0.0
+ 0.5.0
+ 1.5.2.RELEASE
+ 1.8
+ 1.8
+ 2.0.0.Final
+ 1.4.0.Final
@@ -57,6 +62,32 @@
spring-boot-maven-plugin
${spring.boot.version}
+
+
+
+
+ org.xolstice.maven.plugins
+ protobuf-maven-plugin
+ ${protoc.plugin.version}
+
+ com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
+ grpc-java
+ io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
+
+
+
+
+ compile
+ compile-custom
+
+
+
+
+
+ kr.motd.maven
+ os-maven-plugin
+ ${os.plugin.version}
+