spring-remoting-grpc

Spring RPC support over gRPC

License

License

Categories

Categories

gRPC Net Networking
GroupId

GroupId

com.github.vaibhav-sinha
ArtifactId

ArtifactId

spring-remoting-grpc
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

spring-remoting-grpc
Spring RPC support over gRPC
Project URL

Project URL

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

Source Code Management

http://github.com/vaibhav-sinha/spring-remoting-grpc/tree/master

Download spring-remoting-grpc

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.vaibhav-sinha/spring-remoting-grpc/ -->
<dependency>
    <groupId>com.github.vaibhav-sinha</groupId>
    <artifactId>spring-remoting-grpc</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.vaibhav-sinha/spring-remoting-grpc/
implementation 'com.github.vaibhav-sinha:spring-remoting-grpc:0.1.0'
// https://jarcasting.com/artifacts/com.github.vaibhav-sinha/spring-remoting-grpc/
implementation ("com.github.vaibhav-sinha:spring-remoting-grpc:0.1.0")
'com.github.vaibhav-sinha:spring-remoting-grpc:jar:0.1.0'
<dependency org="com.github.vaibhav-sinha" name="spring-remoting-grpc" rev="0.1.0">
  <artifact name="spring-remoting-grpc" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.vaibhav-sinha', module='spring-remoting-grpc', version='0.1.0')
)
libraryDependencies += "com.github.vaibhav-sinha" % "spring-remoting-grpc" % "0.1.0"
[com.github.vaibhav-sinha/spring-remoting-grpc "0.1.0"]

Dependencies

compile (7)

Group / Artifact Type Version
org.springframework : spring-core jar 4.3.9.RELEASE
org.springframework : spring-context jar 4.3.9.RELEASE
org.springframework : spring-beans jar 4.3.9.RELEASE
org.springframework : spring-web jar 4.3.9.RELEASE
io.grpc : grpc-netty jar 1.4.0
io.grpc : grpc-protobuf jar 1.4.0
io.grpc : grpc-stub jar 1.4.0

test (2)

Group / Artifact Type Version
org.springframework : spring-test jar 4.3.9.RELEASE
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

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.

Versions

Version
0.1.0