An open API service indexing awesome lists of open source software.

https://github.com/vaibhav-sinha/spring-remoting-grpc

This library enables using Spring Remoting with gRPC as the underlying transport.
https://github.com/vaibhav-sinha/spring-remoting-grpc

grpc grpc-java java java8 protobuf protobuf3 remoting rpc spring springframework

Last synced: 29 days ago
JSON representation

This library enables using Spring Remoting with gRPC as the underlying transport.

Awesome Lists containing this project

README

          

# Spring Remoting gRPC

This library enables using Spring Remoting with gRPC as the underlying transport.

## Installation

The artifact is available on Maven Central Repository and can be downloaded by adding the following dependency in pom.xml


com.github.vaibhav-sinha
spring-remoting-grpc
0.1.0

## Usage

Create a Service Exporter bean in the context of the service you want to expose

@Bean
public GrpcInvokerServiceExporter userServiceServer() {
GrpcInvokerServiceExporter grpcInvokerServiceExporter = new GrpcInvokerServiceExporter();
grpcInvokerServiceExporter.setServiceInterface(UserService.class);
grpcInvokerServiceExporter.setService(userService());
grpcInvokerServiceExporter.setPort(8888);
return grpcInvokerServiceExporter;
}

Create a Proxy of the service on the client end

@Bean
public UserService userServiceClient() throws Exception {
return (UserService) grpcInvokerProxyFactoryBean().getObject();
}

@Bean
public GrpcInvokerProxyFactoryBean grpcInvokerProxyFactoryBean() {
GrpcInvokerProxyFactoryBean grpcInvokerProxyFactoryBean = new GrpcInvokerProxyFactoryBean();
grpcInvokerProxyFactoryBean.setServiceUrl("localhost:8888");
grpcInvokerProxyFactoryBean.setServiceInterface(UserService.class);
return grpcInvokerProxyFactoryBean;
}

Look in the tests to find the complete example.