Implementation:Apache Dolphinscheduler NettyRemotingClient SendSync
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Systems, RPC |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
Concrete tool for executing synchronous RPC calls using NettyRemotingClient.sendSync() with Transporter wire protocol and ResponseFuture blocking.
Description
NettyRemotingClient manages Netty channels to remote servers and provides sendSync() for blocking RPC calls. It maintains a channel cache per host, automatically reconnecting on channel inactivity. The sendSync() method creates a ResponseFuture, sends the Transporter message via the channel, and blocks until the response arrives. SyncClientMethodInvoker bridges the proxy invocation to sendSync().
Usage
Used internally by ClientInvocationHandler when a proxy method is called. Not typically invoked directly by application code.
Code Reference
Source Location
- Repository: dolphinscheduler
- File: dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/client/NettyRemotingClient.java (L115-191)
- File: dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/protocal/Transporter.java (L34-48)
- File: dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/client/SyncClientMethodInvoker.java (L34-38)
Signature
public class NettyRemotingClient implements AutoCloseable {
public NettyRemotingClient(NettyClientConfig clientConfig);
public IRpcResponse sendSync(SyncRequestDto syncRequestDto);
private void doSendSync(Host host, Transporter transporter,
ResponseFuture responseFuture);
public Channel getOrCreateChannel(Host host);
private Channel createChannel(Host host);
public void onChannelInactive(Host host);
@Override public void close();
}
@Data
public class Transporter {
private TransporterHeader header;
private byte[] body;
public static Transporter of(TransporterHeader header, byte[] body);
public static Transporter of(TransporterHeader header, StandardRpcRequest request);
public static Transporter of(TransporterHeader header, StandardRpcResponse response);
}
Import
import org.apache.dolphinscheduler.extract.base.client.NettyRemotingClient;
import org.apache.dolphinscheduler.extract.base.protocal.Transporter;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| syncRequestDto | SyncRequestDto | Yes | Contains Transporter, target Host, and timeout |
| transporter | Transporter | Yes | Wire-format message with header and serialized body |
Outputs
| Name | Type | Description |
|---|---|---|
| IRpcResponse | Interface | Response containing serialized return value or exception |
| RemoteException | Exception | Thrown on connection failure |
| RemoteTimeoutException | Exception | Thrown when ResponseFuture times out |
Usage Examples
Internal Sync Call Flow
// Inside SyncClientMethodInvoker.invoke():
SyncRequestDto syncRequestDto = SyncRequestDto.builder()
.transporter(Transporter.of(header, standardRpcRequest))
.serverHost(Host.of(hostAddress))
.timeoutMills(rpcMethod.timeout())
.build();
IRpcResponse response = nettyRemotingClient.sendSync(syncRequestDto);
// Deserialize response body to method return type
return JsonSerializer.deserialize(response.getBody(), returnType);