Skip to main content

59 docs tagged with "java"

View All Tags

How to create a Temporal Client in Java

To initialize a Workflow Client, create an instance of a `WorkflowClient`, create a client-side `WorkflowStub`, and then call a Workflow method (annotated with the `@WorkflowMethod` annotation).

How to customize Activity Type in Java

The Activity Type defaults to method name with the first letter of the method name capitalized, and can be customized using `namePrefix()` or `{}` to ensure they are distinct.

How to emit metrics in Java

To emit metrics with the Java SDK, use `WorkflowServiceStubsOptions.Builder.setMetricsScope` to set the metrics scope in your Worker or Client code.

How to get the result of a Workflow Execution in Java

A synchronous Workflow Execution blocks your client thread until the Workflow Execution completes (or fails) and get the results (or error in case of failure). An asynchronous Workflow Execution immediately returns a value to the caller.

How to Heartbeat an Activity in Java

To inform the Temporal service that the Activity is still alive, use `Activity.getExecutionContext().heartbeat()` in the Activity implementation code.

How to send a Query in Java

To send a Query to a Workflow Execution from an external process, call the Query method (defined in the Workflow) from a `WorkflowStub` within the Client code.

How to send a Signal from a Workflow in Java

To send a Signal from within a Workflow to a different Workflow Execution, initiate an `ExternalWorkflowStub` in the implementation of the current Workflow and call the Signal method defined in the other Workflow.

How to set Workflow Timeouts in Java

Set the Workflow Execution Timeout with the `WorkflowStub` instance in the Client code using `WorkflowOptions.Builder.setWorkflowExecutionTimeout`.

How to spawn a Child Workflow Execution in Java

The first call to the Child Workflow stub can be synchronous or asynchronous using `Async.function(Functions.Func)` or `Async.procedure(Functions.Proc)`, and must always be to a method annotated with `@WorkflowMethod`.

How to use Queries in Java

Define a Query method inside the Workflow interface, annotated with the `@QueryMethod` annotation and call the method from an external process.

How to use Signals in Java

Initiate the Signal method with `@SignalMethod` annotation in the Workflow interface and call it either directly from the Client or from within another Workflow.

Queries in Java

Workflow queries can be used to query a Workflow state by external processes at any time during its execution.