3.2.7 gRPC Task
Use a gRPC task to invoke a unary gRPC method from a workflow. The task uses gRPC server reflection to discover the service, method, request message, and response message descriptors at runtime. The target gRPC server must have server reflection enabled.
Currently, only REFLECTION mode is supported. PROTO file-based
invocation is not supported from the Workflow Builder.
To add a gRPC Task
-
Navigate to the Task tab in a workflow and view all the tasks that you can add using the Workflow Builder. See Access the Task Tab in Workflow Builder.
- In the More Tasks dialog box, click gRPC Task to add it to the workflow.
-
Click the task that you have added in the left pane. The Task tab in the right pane displays details about the task, such as its name and parameters. Next, let's provide details for the task.
-
In the Task Details group, enter the following information.
- Task Name: Mandatory. Enter a unique name for the task. The name must be between 1 to 128 alphanumeric characters in length and cannot contain spaces or any special characters. Optionally, you can use underscore (_) and hyphen (-).
- Task Reference: Mandatory. Enter a value to refer to the task within a workflow definition. This value must be unique within a workflow. The task reference value must be between 1 to 128 alphanumeric characters in length and cannot contain spaces or any special characters. Optionally, you can use underscore (_) and hyphen (-).
- In the gRPC Task Parameters group, provide
the following information.
- Host: Mandatory. The network address
of the gRPC server to call. For example,
localhostormy-grpc-service.example.com. - Port : Mandatory. The port on which the target gRPC server is listening.
- Service Name: Mandatory. The fully
qualified gRPC service name that contains the RPC method you want to
invoke. For example,
example.echo.EchoService. - Method Name: Mandatory. The unary
RPC method to invoke on the specified service. For example,
Echo. - Mode: The descriptor resolution mode
for the gRPC call. Currently, only
REFLECTIONmode is supported. In this mode, MicroTx Workflows uses server reflection to discover services and methods without requiring PROTO files. - Metadata: Optional. Task metadata in the workflow definition. Do not use this field for gRPC request headers unless metadata header support is available in your environment.
- Payload: The request message body for the gRPC method, expressed as JSON. The JSON structure must match the protobuf request message expected by the target method.
- Host: Mandatory. The network address
of the gRPC server to call. For example,
-
Click Save to save the changes to the workflow.
MicroTx Workflows displays the changes in JSON code.
-
Review all the changes, and then click Confirm Save to save the changes.
If you do not want to save the changes, click Cancel, and then click Reset to undo all the changes that you have made since the workflow was last saved.
Example
The following example invokes the unary Echo method on the
example.echo.EchoService service using server reflection. In
this example, the target gRPC server must expose the
example.echo.EchoService service through server reflection, and
the Echo method must be a unary method whose request message
contains a message field.
{
"name": "grpc_reflection_example",
"description": "Invokes a unary gRPC method using server reflection",
"version": 1,
"tasks": [
{
"name": "grpc_0",
"taskReferenceName": "grpc_0",
"type": "GRPC",
"inputParameters": {
"host": "localhost",
"port": 50051,
"serviceName": "example.echo.EchoService",
"methodName": "Echo",
"payload": {
"message": "hello"
},
"mode": "REFLECTION"
}
}
],
"inputParameters": [],
"outputParameters": {},
"schemaVersion": 2,
"restartable": true,
"workflowStatusListenerEnabled": false,
"failureWorkflow": "",
"timeoutPolicy": "ALERT_ONLY",
"timeoutSeconds": 0
}
Parent topic: Create System Tasks and Operator Tasks