RPC
查看 MarkdownThis page lists the Java SDK names for RPCs. The doc comment of each API gives its parameters, defaults, and errors. Read them in the Java SDK API reference.
API names
| Task | Java API | Dex behavior |
|---|---|---|
| Define an RPC handler | @RPC on a Flow method | Flow definition |
| Set the durable RPC name | name of @RPC. It defaults to the method name. | Flow definition |
| Set the RPC timeout | timeoutSeconds of @RPC | RPC timeout |
| Lock Attributes for the whole call | lockAttributes and lockAttributeMaps of @RPC, with @RPCAttributeMapLock | Locks |
| Request transactional reads and writes without locks | isTransactional of @RPC | Transactional RPCs |
| Load AttributeMap values and Channel messages | loadAttributeMaps, loadAttributeMapInstances, loadChannels, loadChannelMaps, and loadChannelMapInstances of @RPC | Selective state loading |
| Return the output and start next Steps | RPCResult.of | RPCs |
| Cancel running Steps | RPCResult.withCancelingSteps | Cancel running Steps |
| Let a person invoke the RPC from Dex Web | Not available in the Java SDK. | Actions |
| Invoke the RPC from a Client | Client.invokeRPC, on a stub from Client.newRpcStub | Invoke an RPC |
| Lock or load map instances chosen at call time | RPCInvokeOptions | Runtime-selected map instances |
An RPC method takes a Context, optionally followed by one input. It returns void or an RPCResult. The lock and load elements of @RPC take registered names. An exact map instance uses the form MapName/instance.
RPC stubs and Kotlin
Client.newRpcStub creates a subclass of the Flow. A Java Flow class and its RPC methods must not be final. Kotlin makes both final by default, so declare the Flow class and its RPC methods with open.
Example
Example: examples/java/src/main/java/io/superdurable/dex/primitives/rpc/RpcFlow.java