Implementation:Apache Dolphinscheduler RpcService Annotation
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Systems, RPC |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
Concrete tool for defining RPC service contracts using @RpcService and @RpcMethod annotations in the DolphinScheduler extract framework.
Description
@RpcService is a runtime-retained, type-level annotation marking an interface as an RPC service contract. @RpcMethod is a method-level annotation with optional timeout (default -1, meaning no timeout) and retry (@RpcMethodRetryStrategy) parameters. Together they enable the framework to generate client proxies and register server handlers from annotated interfaces.
Usage
Annotate service interfaces with @RpcService and their methods with @RpcMethod to define RPC contracts. Place these interfaces in dolphinscheduler-extract-{module} for shared access.
Code Reference
Source Location
- Repository: dolphinscheduler
- File: dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/RpcService.java (L26-28)
- File: dolphinscheduler-extract/dolphinscheduler-extract-base/src/main/java/org/apache/dolphinscheduler/extract/base/RpcMethod.java (L26-33)
- File: dolphinscheduler-extract/dolphinscheduler-extract-master/src/main/java/org/apache/dolphinscheduler/extract/master/IWorkflowControlClient.java (L42-67) (example)
Signature
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface RpcService {
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface RpcMethod {
long timeout() default -1;
RpcMethodRetryStrategy retry() default @RpcMethodRetryStrategy;
}
Import
import org.apache.dolphinscheduler.extract.base.RpcService;
import org.apache.dolphinscheduler.extract.base.RpcMethod;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Service interface | Java interface | Yes | Interface annotated with @RpcService |
| Method definitions | Java methods | Yes | Methods annotated with @RpcMethod with request/response types |
Outputs
| Name | Type | Description |
|---|---|---|
| RPC contract | Annotated interface | Shared contract used by proxy factory and server handler |
| Method metadata | Annotations | Timeout and retry configuration per method |
Usage Examples
Workflow Control Contract
@RpcService
public interface IWorkflowControlClient {
@RpcMethod
WorkflowManualTriggerResponse manualTriggerWorkflow(
WorkflowManualTriggerRequest workflowManualTriggerRequest);
@RpcMethod
WorkflowBackfillTriggerResponse backfillTriggerWorkflow(
WorkflowBackfillTriggerRequest workflowBackfillTriggerRequest);
@RpcMethod
WorkflowScheduleTriggerResponse scheduleTriggerWorkflow(
WorkflowScheduleTriggerRequest workflowScheduleTriggerRequest);
@RpcMethod
WorkflowInstancePauseResponse pauseWorkflowInstance(
WorkflowInstancePauseRequest workflowInstancePauseRequest);
@RpcMethod
WorkflowInstanceStopResponse stopWorkflowInstance(
WorkflowInstanceStopRequest workflowInstanceStopRequest);
}
Task Executor Event Listener Contract
@RpcService
public interface ITaskExecutorEventListener {
@RpcMethod
void onTaskExecutorDispatched(TaskExecutorDispatchedLifecycleEvent event);
@RpcMethod
void onTaskExecutorRunning(TaskExecutorStartedLifecycleEvent event);
@RpcMethod
void onTaskExecutorSuccess(TaskExecutorSuccessLifecycleEvent event);
@RpcMethod
void onTaskExecutorFailed(TaskExecutorFailedLifecycleEvent event);
}