Annotation Interface TemporalOperation
Marks a method on a
ServiceImpl-annotated class as a Temporal-backed Nexus operation. The
method body is the start handler — the framework wraps it in a TemporalOperationHandler at registration time, with default cancel behavior matching TemporalOperationHandler.cancel(OperationContext, OperationCancelDetails).
The declaring ServiceImpl-annotated class must be public so the annotated
method can be accessed at registration time. The method must:
- be
public, - accept exactly three parameters:
TemporalOperationStartContext,TemporalNexusClient, and the operation input type, - return
TemporalOperationResult.
Workflow-run example:
@ServiceImpl(service = TransferService.class)
public class TransferServiceImpl {
@TemporalOperation
public TemporalOperationResult<TransferResult> transfer(
TemporalOperationStartContext ctx, TemporalNexusClient client, TransferInput input) {
return client.startWorkflow(
TransferWorkflow.class,
TransferWorkflow::transfer,
input,
WorkflowOptions.newBuilder()
.setWorkflowId("transfer-" + input.getTransferId())
.build());
}
}
For custom cancel, or any other handler composition, use OperationImpl with a TemporalOperationHandler subclass that overrides TemporalOperationHandler.cancelWorkflowRun(io.temporal.nexus.TemporalOperationCancelContext, io.temporal.nexus.CancelWorkflowRunInput). Both annotations can coexist on the same ServiceImpl class, but never on the same method.