This project integrates GRPC with Eureka, the best way to understand how it works is to look at the example code
The server does not need any special setup, it should just start GRPC the usual way and register itself to Eureka the usual way
- Add the starter dependency to your project
<parent>
<groupId>com.github.exampledriven</groupId>
<artifactId>grpc-eureka-java-starter</artifactId>
<version>version</version>
</parent>
-
Set the
grpc.eureka.service-id
property to the service id of your server -
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);
}
- Add the following dependency
<parent>
<groupId>com.github.exampledriven</groupId>
<artifactId>grpc-eureka-java</artifactId>
<version>version</version>
</parent>
- 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();