Skip to content

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

License

Notifications You must be signed in to change notification settings

vaibhav-sinha/spring-remoting-grpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

<dependency>
    <groupId>com.github.vaibhav-sinha</groupId>
    <artifactId>spring-remoting-grpc</artifactId>
    <version>0.1.0</version>
</dependency>

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.

Releases

No releases published

Packages

No packages published