How to Continue-As-New in Java
To cause a Workflow to Continue-As-New, use `Workflow.continueAsNew()`.
To cause a Workflow to Continue-As-New, use `Workflow.continueAsNew()`.
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).
The Activity Type defaults to method name with the first letter of the method name capitalized, and can be customized using `namePrefix()` or `{ActivityMethod.name()}` to ensure they are distinct.
The Workflow Type defaults to the short name of the Workflow interface, and can be customized with the `name` parameter.
Create a Query handler using the `@QueryMethod` annotation in the Workflow interface.
An Activity interface can have any number of parameters.
Activity return values must be serializable and deserializable by the provided `DataConverter`
Define a Signal method with `@SignalMethod` annotation in the Workflow interface.
A method annotated with `@WorkflowMethod` can have any number of parameters.
Workflow method arguments and return values must be serializable and deserializable using the provided `DataConverter`.
Use the `newWorker` method on an instance of a `WorkerFactory` to create a new Worker in Java.
In the Temporal Java SDK programming model, a Workflow is a class which implements a Workflow interface.
In the Temporal Java SDK programming model, a Workflow is a class which implements a Workflow interface.
In the Temporal Java SDK programming model, Activities are classes which implement the Activity Interface.
In the Temporal Java SDK programming model, Activities are classes which implement the Activity Interface.
To emit metrics with the Java SDK, use `WorkflowServiceStubsOptions.Builder.setMetricsScope` to set the metrics scope in your Worker or Client code.
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.
To get the results of an asynchronously invoked Activity method, use the `Promise` `get` method to block until the Activity method result is available.
To handle a Query in a Workflow, define a Query handler method using the `@QueryMethod` annotation in the Workflow interface.
Use the `@SignalMethod` annotation to handle Signals within the Workflow interface.
When defining Workflows using the Temporal Java SDK, the Workflow code must be written to execute effectively once and to completion.
To inform the Temporal service that the Activity is still alive, use `Activity.getExecutionContext().heartbeat()` in the Activity implementation code.
Providing authorization header to Temporal Server in Java SDK including JWT tokens
Use the `RegisterNamespaceRequest` API to register a Namespace and set the Retention Period for the Workflow Execution Event History for the Namespace.
Use `worker.registerWorkflowImplementationTypes` to register Workflow Type and `worker.registerActivitiesImplementations` to register Activity implementation with Workers.
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.
To send a Signal to a Workflow Execution from a Client, call the Signal method, annotated with `@SignalMethod` in the Workflow interface, from the Client code.
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.
To send Signals to a Workflow Execution whose status is unknown, use `SignalWithStart` with a `WorkflowStub` in the Client code.
Set the Cron Schedule with the `WorkflowStub` instance in the Client code using [`WorkflowOptions.Builder.setCronSchedule`
Set the Workflow Id with the `WorkflowStub` instance in the Client code using `WorkflowOptions.Builder.setWorkflowId`.
To set a Heartbeat Timeout, use `ActivityOptions.newBuilder.setHeartbeatTimeout`].
Use the setNamespace method on Workflow Client Options Builder.
To set a Schedule-To-Close Timeout, use `ActivityOptions.newBuilder.setScheduleToCloseTimeout`].
To set a Schedule-To-Start Timeout, use `ActivityOptions.newBuilder.setScheduleToStartTimeout`].
To set a Start-To-Close Timeout, use `ActivityOptions.newBuilder.setStartToCloseTimeout`].
Set the Workflow Execution Timeout with the `WorkflowStub` instance in the Client code using `WorkflowOptions.Builder.setWorkflowExecutionTimeout`.
Set the Workflow Run Timeout with the `WorkflowStub` instance in the Client code using `WorkflowOptions.Builder.setWorkflowRunTimeout`.
Set the Workflow Task Timeout with the `WorkflowStub` instance in the Client code using `WorkflowOptions.Builder.setWorkflowTaskTimeout`.
To set a Heartbeat Timeout, use `ActivityOptions.newBuilder.setHeartbeatTimeout`].
Activity Timeouts
Use `ActivityOptions` to configure how to invoke an Activity Execution.
Set Child Workflow specific options with the `ChildWorkflowOptions` class.
To set the mTLS configuration in Java, provide the certificate and private key in an instance of `WorkflowServiceStub`.
Set `Parent Close Policy` on an instance of `ChildWorkflowOptions` using `ChildWorkflowOptions.newBuilder().setParentClosePolicy`.
Set the Workflow Task Queue with the `WorkflowStub` instance in the Client code using `WorkflowOptions.Builder.setTaskQueue`.
Set Workflow Retry Options in the `WorkflowStub` instance using `WorkflowOptions.Builder.setWorkflowRetryOptions`.
Set the Workflow Execution Timeout with the `WorkflowStub` instance in the Client code using `WorkflowOptions.Builder.setWorkflowExecutionTimeout`.
Set `WorkflowClient` specific options with the `WorkflowClientOptions` class.
Set `WorkflowServiceStub` specific options with the `WorkflowServiceStubOptions` class.
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`.
Use `WorkflowStub` to start a Workflow Execution from within a Client, and `ExternalWorkflowStub` to start a different Workflow Execution from within a Workflow.
Invoke Activities using `Workflow.newActivityStub`(type-safe) or `Workflow.newUntypedActivityStub` (untyped) from within a Workflow.
A Side Effect is a method of execution to produce nondeterministic code.
Define a Query method inside the Workflow interface, annotated with the `@QueryMethod` annotation and call the method from an external process.
Initiate the Signal method with `@SignalMethod` annotation in the Workflow interface and call it either directly from the Client or from within another Workflow.
Add the Temporal Java SDK to your project.
Use `ActivityOptions` to configure how to invoke an Activity Execution.
Workflow queries can be used to query a Workflow state by external processes at any time during its execution.
Signal methods can only be defined inside Workflows Interfaces and are methods annotated with the @SignalMethod annotation, for example: