Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unified dependencies version #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<module>chat-javafx-client</module>
<module>metadata-context-example</module>
<module>zipkin-prometheus-example</module>
<module>springboot</module>
<!--
<module>springboot</module>
-->
Expand Down

This file was deleted.

17 changes: 17 additions & 0 deletions springboot/eureka-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -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
72 changes: 53 additions & 19 deletions springboot/grpc-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>springboot-grpc-client</artifactId>

<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
Expand All @@ -42,30 +59,20 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>springboot-grpc-server</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.saturnism.springboot</groupId>
<artifactId>grpc-server-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.saturnism.springboot</groupId>
<artifactId>grpc-client-starter</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
</dependencies>

<build>
Expand All @@ -75,5 +82,32 @@
<artifactId>os-maven-plugin</artifactId>
</extension>
</extensions>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>${protoc.plugin.version}</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>${os.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions springboot/grpc-client/src/main/proto/Echo.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

package com.example.echo;

message Echo {
string message = 1;
}

service EchoService {
rpc echo(Echo) returns (Echo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions springboot/grpc-client/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="6 seconds">

<property name="LOG_HOME" value="/data/weblog/tomcat/zbase.yyembed.yy.com" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%date{yyyy-MM-dd HH:mm:ss} [%thread] %-5level [%file:%line] - %msg%n
</pattern>
</encoder>
</appender>

<root level="WARN">
<appender-ref ref="STDOUT" />
</root>
</configuration>
16 changes: 16 additions & 0 deletions springboot/grpc-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EchoOuterClass.Echo> responseObserver) {
System.out.println(request);
System.out.println("####################" + request + " port ");
responseObserver.onNext(request);
responseObserver.onCompleted();
}
Expand Down

This file was deleted.

19 changes: 19 additions & 0 deletions springboot/grpc-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -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
47 changes: 39 additions & 8 deletions springboot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>grpc-demos</artifactId>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>springboot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
<spring.boot.version>1.3.5.RELEASE</spring.boot.version>
<spring.cloud.version>Brixton.RELEASE</spring.cloud.version>
<spring.boot.version>1.5.2.RELEASE</spring.boot.version>
<spring.cloud.version>Dalston.RELEASE</spring.cloud.version>
<grpc.version>1.0.0</grpc.version>
<protoc.version>3.0.0</protoc.version>
<protoc.plugin.version>0.5.0</protoc.plugin.version>
<spring.boot.version>1.5.2.RELEASE</spring.boot.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<netty.version>2.0.0.Final</netty.version>
<os.plugin.version>1.4.0.Final</os.plugin.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -57,6 +62,32 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
</plugin>



<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>${protoc.plugin.version}</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>${os.plugin.version}</version>
</plugin>
</plugins>
</build>

Expand Down