Skip to content

ExampleDriven/grpc-eureka-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central

Build Status

GRPC, Eureka integration in Java

This project integrates GRPC with Eureka, the best way to understand how it works is to look at the example code

Server setup

The server does not need any special setup, it should just start GRPC the usual way and register itself to Eureka the usual way

Client setup

Using the Spring Boot Starter

  1. Add the starter dependency to your project
    <parent>
        <groupId>com.github.exampledriven</groupId>
        <artifactId>grpc-eureka-java-starter</artifactId>
        <version>version</version>
    </parent>
  1. Set the grpc.eureka.service-id property to the service id of your server

  2. A default instance of ManagedChannel is auto created for you. You can use it like this

    @Autowired
    ManagedChannel managedChannel;
    
    @PostConstruct
    private void initializeClient() {

        bookServiceBlockingStub = BookServiceGrpc.newBlockingStub(managedChannel);

    }     
    

Without using Spring Boot Starter

  1. Add the following dependency
    <parent>
        <groupId>com.github.exampledriven</groupId>
        <artifactId>grpc-eureka-java</artifactId>
        <version>version</version>
    </parent>
  1. You have to manually create an instance of ManagedChannel like this
        return ManagedChannelBuilder
                .forTarget("eureka://" + eurekaServiceId)
                .nameResolverFactory(new EurekaNameResolverProvider(eurekaClientConfig, "grpc.port"))
                .loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance())
                .usePlaintext(true)
                .build();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages