High-performance in-process transport implementation for gRPC Java that enables direct communication between client and server within the same JVM process
npx @tessl/cli install tessl/maven-io-grpc--grpc-inprocess@1.73.00
# gRPC In-Process Transport
1
2
gRPC In-Process Transport provides a high-performance transport implementation for gRPC Java that enables direct communication between client and server within the same JVM process. This transport bypasses network serialization entirely while maintaining full gRPC semantics and features including streaming, metadata, deadlines, and cancellation.
3
4
## Package Information
5
6
- **Package Name**: grpc-inprocess
7
- **Package Type**: maven
8
- **Language**: Java
9
- **Installation**:
10
```xml
11
<dependency>
12
<groupId>io.grpc</groupId>
13
<artifactId>grpc-inprocess</artifactId>
14
<version>1.73.0</version>
15
</dependency>
16
```
17
18
Gradle:
19
```gradle
20
implementation 'io.grpc:grpc-inprocess:1.73.0'
21
```
22
23
## Core Imports
24
25
```java
26
import io.grpc.inprocess.InProcessChannelBuilder;
27
import io.grpc.inprocess.InProcessServerBuilder;
28
import io.grpc.inprocess.InProcessSocketAddress;
29
import io.grpc.inprocess.AnonymousInProcessSocketAddress;
30
```
31
32
## Basic Usage
33
34
```java
35
import io.grpc.inprocess.InProcessChannelBuilder;
36
import io.grpc.inprocess.InProcessServerBuilder;
37
import io.grpc.Channel;
38
import io.grpc.Server;
39
import java.util.concurrent.TimeUnit;
40
41
// Generate unique server name for testing
42
String serverName = InProcessServerBuilder.generateName();
43
44
// Create and start in-process server
45
Server server = InProcessServerBuilder.forName(serverName)
46
.directExecutor() // Use direct executor for testing
47
.addService(new MyGrpcService()) // Add your gRPC service
48
.build()
49
.start();
50
51
// Create client channel to connect to the server
52
Channel channel = InProcessChannelBuilder.forName(serverName)
53
.directExecutor()
54
.build();
55
56
// Use channel with your gRPC stubs
57
MyServiceGrpc.MyServiceBlockingStub stub =
58
MyServiceGrpc.newBlockingStub(channel);
59
60
// Make gRPC calls
61
MyResponse response = stub.myMethod(MyRequest.newBuilder().build());
62
```
63
64
## Architecture
65
66
The gRPC In-Process Transport is built around several key components:
67
68
- **Builders**: `InProcessChannelBuilder` and `InProcessServerBuilder` provide fluent APIs for creating channels and servers
69
- **Socket Addresses**: `InProcessSocketAddress` and `AnonymousInProcessSocketAddress` identify server endpoints
70
- **Transport Layer**: Internal transport implementation that provides direct method invocation and shared memory communication
71
- **Server Registry**: Static registry that maps server names to server instances for named servers
72
- **Executor Integration**: Support for custom and shared executor services for optimal performance
73
74
## Capabilities
75
76
### Channel Building
77
78
Create in-process channels that connect to named or addressed servers with comprehensive configuration options.
79
80
```java { .api }
81
public static InProcessChannelBuilder forName(String name);
82
public static InProcessChannelBuilder forTarget(String target);
83
public static InProcessChannelBuilder forAddress(SocketAddress address);
84
```
85
86
[Channel Building](./channel-builder.md)
87
88
### Server Building
89
90
Create in-process servers that can be identified by name or anonymous address with full gRPC server capabilities.
91
92
```java { .api }
93
public static InProcessServerBuilder forName(String name);
94
public static InProcessServerBuilder forAddress(SocketAddress listenAddress);
95
public static String generateName();
96
```
97
98
[Server Building](./server-builder.md)
99
100
### Socket Addresses
101
102
Addressing system for in-process servers supporting both named and anonymous server identification.
103
104
```java { .api }
105
public final class InProcessSocketAddress extends SocketAddress {
106
public InProcessSocketAddress(String name);
107
public String getName();
108
}
109
110
public final class AnonymousInProcessSocketAddress extends SocketAddress {
111
public AnonymousInProcessSocketAddress();
112
}
113
```
114
115
[Socket Addresses](./socket-addresses.md)
116
117
## Performance Features
118
119
- **Zero Network Overhead**: Direct method invocation within the same JVM process
120
- **Message Size Assumptions**: Configure assumed message sizes to skip serialization for metrics
121
- **Executor Service Management**: Shared executor pools for optimal resource usage
122
- **Stats Recording**: Optional stats recording that can be disabled for maximum performance
123
124
## Use Cases
125
126
- **Testing**: Fast and reliable gRPC interactions in unit and integration tests
127
- **Microservice Architectures**: Efficient communication between components in the same application
128
- **High-Throughput Systems**: Maximum performance scenarios where network latency would be a bottleneck
129
- **Development**: Rapid prototyping and development without network configuration complexity