### Start Example Starter Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexusmessaging/callerpattern/README.md Initiates the example execution by starting the caller starter. This orchestrates the interaction between the caller and handler. ```bash ./gradlew -q :core:execute -PmainClass=io.temporal.samples.nexusmessaging.callerpattern.caller.CallerStarter ``` -------------------------------- ### Execute Sample with Gradle Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/workerversioning/README.md Run the main application to start the worker versioning sample. This command guides you through the sample's execution. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.Starter ``` -------------------------------- ### Start Starter Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/sleepfordays/README.md Execute this command to start the Temporal starter for the sleep-for-days sample. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.sleepfordays.Starter ``` -------------------------------- ### Start Starter Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/getresultsasync/README.md Execute this command to start the Temporal Starter, which initiates Workflows. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.getresultsasync.Starter ``` -------------------------------- ### Start Starter with Metrics Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/metrics/README.md Execute this command to start the starter with metrics enabled. The starter's metrics will be available at http://localhost:8078/metrics. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.metrics.MetricsStarter ``` -------------------------------- ### Run Nexus Messaging On-Demand Example Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexusmessaging/ondemandpattern/README.md Executes the main entry point for the Nexus Messaging on-demand pattern sample. This command starts the caller workflow that interacts with remote workflows. ```bash ./gradlew -q :core:execute -PmainClass=io.temporal.samples.nexusmessaging.ondemandpattern.caller.CallerRemoteStarter ``` -------------------------------- ### Start SpringBoot Application Source: https://github.com/temporalio/samples-java/blob/main/springboot/src/main/java/io/temporal/samples/springboot/camel/README.md Run this command from the main samples repo directory to start the Spring Boot application. ```bash ./gradlew :springboot:bootRun ``` -------------------------------- ### Clone Temporal Java Samples Repository Source: https://github.com/temporalio/samples-java/blob/main/README.md Clone the repository to get started with the Temporal Java SDK samples. Navigate into the cloned directory to proceed. ```bash git clone https://github.com/temporalio/samples-java cd samples-java ``` -------------------------------- ### Start Worker with Workflow Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/retryonsignalinterceptor/README.MD Initiates the Temporal worker that runs the workflow. This setup is necessary to begin the sample's execution flow. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.retryonsignalinterceptor.MyWorkflowWorker ``` -------------------------------- ### Start Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/getresultsasync/README.md Execute this command to start the Temporal Worker for the sample. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.getresultsasync.Worker ``` -------------------------------- ### Start Auto-Heartbeating Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/autoheartbeat/README.md Execute the sample starter class using Gradle to run the auto-heartbeating demonstration. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.autoheartbeat.Starter ``` -------------------------------- ### Start Temporal Dev Server Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/standaloneactivities/README.md Starts the Temporal development server with standalone activity support. Ensure this is running before executing activities. ```bash ./temporal server start-dev ``` -------------------------------- ### Start Temporal Server with Docker Compose Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/encodefailures/README.md Instructions for starting a Temporal Server instance using Docker Compose. Ensure the 'default' namespace is enabled. ```bash git clone https://github.com/temporalio/docker-compose.git cd docker-compose docker-compose up ``` -------------------------------- ### Start DynamicSleepWorkflowStarter Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/updatabletimer/README.md Starts a Workflow Execution. This should be run after the worker has been started. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.updatabletimer.DynamicSleepWorkflowStarter ``` -------------------------------- ### Execute Sample with Gradle Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/asyncuntypedchild/README.md Run the sample's starter class using Gradle. This command initiates the parent workflow, which in turn starts the untyped child workflow. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.asyncuntypedchild.Starter ``` -------------------------------- ### Start Temporal Dev Server Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexus/README.MD Starts a local Temporal development server. The HTTP port is required for Nexus communications. ```bash temporal server start-dev ``` -------------------------------- ### Start Async Package Delivery Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/packetdelivery/README.md Execute the sample by running the Gradle task with the specified main class. This command initiates the asynchronous package delivery simulation. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.packetdelivery.Starter ``` -------------------------------- ### Start Caller Workflow Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexuscontextpropagation/README.MD Initiate a caller workflow using Gradle. This starts the workflow that will interact with Nexus operations. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.nexuscontextpropagation.caller.CallerStarter \ --args="-target-host localhost:7233 -namespace my-caller-namespace" ``` -------------------------------- ### Start Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/sleepfordays/README.md Execute this command to start the Temporal worker for the sleep-for-days sample. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.sleepfordays.Worker ``` -------------------------------- ### Start Docker Compose with Elasticsearch Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/listworkflows/README.md To run this sample, you need to start the Temporal services with Elasticsearch enabled. Use this command if you are using Docker. ```bash git clone https://github.com/temporalio/docker-compose.git cd docker-compose docker-compose -f docker-compose-cas-es.yml up ``` -------------------------------- ### Start Jaeger with Docker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/tracing/README.md Starts a Jaeger all-in-one instance using Docker. Ensure the ports match your configuration if they differ. ```bash docker run -d -p 5775:5775/udp -p 14250:14250 -p 16686:16686 -p 14268:14268 jaegertracing/all-in-one:latest ``` -------------------------------- ### Start Worker with Metrics Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/metrics/README.md Execute this command to start the worker with metrics enabled. The worker's metrics will be available at http://localhost:8077/metrics. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.metrics.MetricsWorker ``` -------------------------------- ### Start Sliding Window Batch Workflow Execution Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/batch/slidingwindow/README.md Execute this command to start a new BatchWorkflow Execution. Each execution starts a new BatchWorkflow. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.batch.slidingwindow.SlidingWindowBatchStarter ``` -------------------------------- ### Handler Workflow Output Example Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexuscancellation/README.MD Example output from the handler side, indicating that the workflow was cancelled successfully. ```text 14:33:54.177 INFO i.t.s.n.h.HelloHandlerWorkflowImpl - HelloHandlerWorkflow was cancelled successfully. 14:33:56.167 INFO i.t.s.n.h.HelloHandlerWorkflowImpl - HelloHandlerWorkflow was cancelled successfully. 14:33:57.172 INFO i.t.s.n.h.HelloHandlerWorkflowImpl - HelloHandlerWorkflow was cancelled successfully. 14:33:57.176 INFO i.t.s.n.h.HelloHandlerWorkflowImpl - HelloHandlerWorkflow was cancelled successfully. ``` -------------------------------- ### Start Cluster Manager Workflow Starter Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/safemessagepassing/README.md Initiates a new workflow execution for the Cluster Manager. This should be run after the worker has started. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.safemessagepassing.ClusterManagerWorkflowStarter ``` -------------------------------- ### Start DynamicSleepWorkflowWorker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/updatabletimer/README.md Starts the worker that hosts the Workflow Executions. This is the first step in running the sample. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.updatabletimer.DynamicSleepWorkflowWorker ``` -------------------------------- ### Run EarlyReturnClient Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/earlyreturn/README.md Execute the client to start a workflow with Update-with-Start. Modify the amount in the client code to test failed initialization. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.earlyreturn.EarlyReturnClient ``` -------------------------------- ### Start Caller Workflow Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexusmultipleargs/README.MD Initiate the caller workflow. This starts the process that will eventually call the Nexus operation. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.nexusmultipleargs.caller.CallerStarter \ --args="-target-host localhost:7233 -namespace my-caller-namespace" ``` -------------------------------- ### Start Transfer Requester Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/moneytransfer/README.MD Execute this command to start the Transfer Requester process. This process initiates new transfer workflows. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.moneytransfer.TransferRequester ``` -------------------------------- ### Start Trip Booking Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/bookingsyncsaga/README.md Run this command to start the Temporal worker for the synchronous trip booking saga. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.bookingsyncsaga.TripBookingWorker ``` -------------------------------- ### Caller Workflow Output Example Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexuscancellation/README.MD Example output from the caller side, showing the workflow ID, run ID, and the final result. ```text 14:33:52.810 i.t.s.n.caller.CallerStarter - Started workflow workflowId: 87e97bf0-ca8a-4ae6-a9dc-ae97e5c0ac41 runId: 01976b36-a524-71a1-b848-8eb385fec2c3 14:33:54.250 i.t.s.n.caller.CallerStarter - Workflow result: Hallo Nexus 👋 ``` -------------------------------- ### Start Activity Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/moneybatch/README.md Starts the activity worker process for the Money Batch sample. This process hosts the activity executions. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.moneybatch.AccountActivityWorker ``` -------------------------------- ### Start Workflow Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/moneytransfer/README.MD Execute this command to start the Workflow Worker process. It hosts the main workflow logic. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.moneytransfer.AccountTransferWorker ``` -------------------------------- ### Start Standalone Activity without Waiting Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/standaloneactivities/README.md Starts a standalone activity without blocking and allows retrieving the result separately. This can be run using Gradle or the Temporal CLI. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.standaloneactivities.StartActivity ``` ```bash ./temporal activity start \ --type ComposeGreeting \ --activity-id standalone-activity-id \ --task-queue standalone-activity-task-queue \ --start-to-close-timeout 10s \ --input '"Hello"' \ --input '"World"' ``` -------------------------------- ### Start Worker Version 2 Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/workerversioning/README.md Launch a worker for version 2.0 of the application. This demonstrates deploying a newer version alongside older ones. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.WorkerV2 ``` -------------------------------- ### Start File Processing Workflow Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/fileprocessing/README.md Initiates a new Workflow Execution for the file processing sample. Each execution of this command starts a distinct Workflow. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.fileprocessing.FileProcessingStarter ``` -------------------------------- ### Start Worker Version 1 Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/workerversioning/README.md Launch a worker for version 1.0 of the application. This is one of the worker versions deployed within the sample. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.WorkerV1 ``` -------------------------------- ### Start Heartbeating Activity Batch Workflow Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/batch/heartbeatingactivity/README.md Execute this command to start a new Workflow Execution for the batch processing. Each execution of this command initiates a distinct Workflow. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.batch.heartbeatingactivity.HeartbeatingActivityBatchStarter ``` -------------------------------- ### Start Caller Workflow Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexuscancellation/README.MD Initiates the caller workflow that will trigger the Nexus operation and demonstrate cancellation. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.nexuscancellation.caller.CallerStarter \ --args="-target-host localhost:7233 -namespace my-caller-namespace" ``` -------------------------------- ### Start Nexus Caller Workflow Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexus/README.MD Initiates the Nexus caller workflow. Provide the target host and namespace for the caller. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.nexus.caller.CallerStarter \ --args="-target-host localhost:7233 -namespace my-caller-namespace" ``` -------------------------------- ### Execute Terminate Workflow Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/terminateworkflow/README.md Run this command to execute the terminate workflow sample. It starts a workflow and then terminates it. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.terminateworkflow.Starter ``` -------------------------------- ### Run Nexus Handler and Caller Source: https://context7.com/temporalio/samples-java/llms.txt Commands to start the Nexus handler worker and then the caller. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.nexus.handler.HandlerWorker ./gradlew -q execute -PmainClass=io.temporal.samples.nexus.caller.CallerStarter ``` -------------------------------- ### Execute Frequent Polling Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/polling/frequent/README.md Run the frequent polling sample using Gradle. This command executes the main class responsible for starting the sample. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.polling.frequent.FrequentPollingStarter ``` -------------------------------- ### Access Web Interface Source: https://github.com/temporalio/samples-java/blob/main/springboot/src/main/java/io/temporal/samples/springboot/hello/README.md Navigate to this URL in your browser after starting the Spring Boot application. This interface allows you to trigger the Temporal workflow by providing input and view its results. ```bash http://localhost:3030/hello ``` -------------------------------- ### Run DSL Sample Starter Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/dsl/README.md Execute the starter class for the DSL sample using Gradle. This command initiates the sample's execution environment. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.dsl.Starter ``` -------------------------------- ### Expected Output of the Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexusmessaging/ondemandpattern/README.md Displays the expected output when the Nexus Messaging on-demand pattern sample is run successfully. It shows the lifecycle of remote workflows from start to completion. ```text started remote greeting workflow: UserId One started remote greeting workflow: UserId Two Supported languages for UserId One: [CHINESE, ENGLISH] Supported languages for UserId Two: [CHINESE, ENGLISH] UserId One changed language: ENGLISH -> ARABIC UserId Two changed language: ENGLISH -> HINDI Workflows approved Workflow one result: مرحبا بالعالم Workflow two result: नमस्ते दुनिया ``` -------------------------------- ### Run Nexus Handler Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexus/README.MD Starts the Nexus handler worker. Ensure to provide the correct target host and namespace. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.nexus.handler.HandlerWorker \ --args="-target-host localhost:7233 -namespace my-target-namespace" ``` -------------------------------- ### Caller Side Output Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexuscontextpropagation/README.MD Example output observed on the caller side after starting workflows. This shows the workflow IDs, run IDs, and results of the executed workflows. ```log INFO i.t.s.n.caller.CallerStarter - Started EchoCallerWorkflow workflowId: 7ac97cb9-b457-4052-af94-d82478c35c5e runId: 01954eb9-6963-7b52-9a1d-b74e64643846 INFO i.t.s.n.caller.CallerStarter - Workflow result: Nexus Echo 👋 INFO i.t.s.n.caller.CallerStarter - Started HelloCallerWorkflow workflowId: 9e0bc89c-5709-4742-b7c0-868464c2fccf runId: 01954eb9-6ae3-7d6d-b355-71545688309d INFO i.t.s.n.caller.CallerStarter - Workflow result: Hello Nexus 👋 ``` -------------------------------- ### Start Worker Version 1.1 Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/workerversioning/README.md Launch a worker for version 1.1 of the application. This represents an intermediate update managed by worker versioning. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.workerversioning.WorkerV1_1 ``` -------------------------------- ### Start Worker with Custom CA using Gradle Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/ssl/README.md Execute the worker that connects to a Temporal cluster with mTLS enabled, using a custom CA certificate, via Gradle. ```bash ./gradlew -q execute -PmainClass="io.temporal.samples.ssl.SslEnabledWorkerCustomCA" ``` -------------------------------- ### Execute Hello World Sample with Gradle Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/hello/README.md Use this command to execute a specific 'Hello World' sample. Replace 'io.temporal.samples.hello.HelloSampleName' with the actual main class of the sample you wish to run. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloAccumulator ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloActivity ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloActivityRetry ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloActivityExclusiveChoice ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloAsync ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloParallelActivity ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloAsyncActivityCompletion ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloAsyncLambda ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloCancellationScope ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloDetachedCancellationScope ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloChild ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloCron ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloDynamic ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloEagerWorkflowStart ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloException ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloLocalActivity ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloPeriodic ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloPolymorphicActivity ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloQuery ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSaga ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSchedules ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSignal ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSearchAttributes ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloTypedSearchAttributes ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSideEffect ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloUpdate ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSignalWithTimer ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSignalWithStartAndWorkflowInit ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloStandaloneActivity ``` -------------------------------- ### Start Cluster Manager Workflow Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/safemessagepassing/README.md Starts the worker process for the Cluster Manager Workflow. This is the first step before starting workflow executions. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.safemessagepassing.ClusterManagerWorkflowWorker ``` -------------------------------- ### Sample Log Output Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/polling/infrequentwithretryafter/README.md Example log output demonstrating the polling attempts, the 'Retry-After' durations, and the final successful result. This illustrates how the Activity retries are influenced by the downstream service's response. ```log Attempt: 1 Poll time: 2024-07-14T22:03:03.750506 Activity next retry in: 2 minutes Attempt: 2 Poll time: 2024-07-14T22:05:03.780079 Activity next retry in: 3 minutes Attempt: 3 Poll time: 2024-07-14T22:08:03.799703 Activity next retry in: 1 minutes Attempt: 4 Poll time: 2024-07-14T22:09:03.817751 Result: OK ``` -------------------------------- ### Worker Startup and Workflow Execution Log Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/ssl/README.md Observe the log output indicating successful connection to the Temporal service and the start of workflow polling. This confirms the worker is operational. ```text [main] INFO i.t.s.WorkflowServiceStubsImpl - Created WorkflowServiceStubs for channel: ManagedChannelOrphanWrapper{delegate=ManagedChannelImpl{logId=1, target=localhost:7233}} [main] INFO io.temporal.internal.worker.Poller - start: Poller{name=Workflow Poller taskQueue="MyTaskQueue", namespace="default"} Workflow completed:done ``` -------------------------------- ### Execute the List Workflows Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/listworkflows/README.md Run the sample application using Gradle. This command specifies the main class to execute for the sample. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.listworkflows.Starter ``` -------------------------------- ### Execute Sample with Gradle Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/ssl/README.md Run the sample application using Gradle. Ensure the main class is correctly specified. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.ssl.Starter ``` -------------------------------- ### Execute Async Child Workflow Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/asyncchild/README.md Run the sample application to observe asynchronous child workflow execution. This command initiates the starter class which orchestrates the parent and child workflows. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.asyncchild.Starter ``` -------------------------------- ### Run Starter for OpenTracing Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/tracing/README.md Executes the Temporal Starter application configured for OpenTracing, passing 'OpenTracing' as an argument. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.opentracing.Starter --args="OpenTracing" ``` -------------------------------- ### Run Temporal Starter with API Key Authentication Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/apikey/README.md Execute the starter component in a new terminal using Gradle to initiate workflows. This starter connects using the previously configured API Key. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.apikey.Starter ``` -------------------------------- ### Run Starter for OpenTelemetry Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/tracing/README.md Executes the Temporal Starter application configured for OpenTelemetry tracing. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.opentracing.Starter ``` -------------------------------- ### Run SpringBoot Basic Sample Source: https://github.com/temporalio/samples-java/blob/main/README.md Execute the basic Spring Boot sample application using Gradle. Ensure you are in the main repository directory. ```bash ./gradlew :springboot-basic:bootRun ``` -------------------------------- ### Start Iterator Batch Workflow Execution Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/batch/iterator/README.md Execute this command to start a new Workflow Execution. Each time this command is run, a new Workflow Execution is initiated. This command starts the parent workflow which in turn orchestrates the child workflows for batch processing. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.batch.iterator.IteratorBatchStarter ``` -------------------------------- ### Run Crypto Payload Converter Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/payloadconverter/crypto/README.md Execute this Gradle command to run the sample application, specifying the main class for the crypto payload converter. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.payloadconverter.crypto.Starter ``` -------------------------------- ### Sample Output Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexusmultipleargs/README.MD Expected output from the caller starter workflow, showing successful Nexus operation calls. ```text [main] INFO i.t.s.nexus.caller.CallerStarter - Workflow result: Nexus Echo 👋 [main] INFO i.t.s.nexus.caller.CallerStarter - Workflow result: ¡Hola! Nexus 👋 ``` -------------------------------- ### Run Spring AI Basic Sample Source: https://github.com/temporalio/samples-java/blob/main/README.md Execute the basic Spring AI sample application using Gradle. Ensure you are in the main repository directory. Requires OPENAI_API_KEY environment variable. ```bash ./gradlew :springai:basic:bootRun ``` -------------------------------- ### Start Workflow Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/moneybatch/README.md Starts the workflow worker process for the Money Batch sample. This process hosts the workflow executions. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.moneybatch.AccountTransferWorker ``` -------------------------------- ### Start Activity Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/moneytransfer/README.MD Execute this command to start the Activity Worker process. It hosts the activity logic that workflows call. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.moneytransfer.AccountActivityWorker ``` -------------------------------- ### Build and Run Tests with Gradle Source: https://github.com/temporalio/samples-java/blob/main/README.md Build the project and run all associated tests using the Gradle wrapper script. This command verifies the integrity of the samples. ```bash ./gradlew build ``` -------------------------------- ### Basic Workflow with Single Activity in Java Source: https://context7.com/temporalio/samples-java/llms.txt Demonstrates the simplest Temporal pattern: defining interfaces, implementing workflow and activity, registering with a worker, and executing synchronously via a stub. Ensure the correct main class is specified when running. ```java // --- Interface definitions --- @WorkflowInterface public interface GreetingWorkflow { @WorkflowMethod String getGreeting(String name); } @ActivityInterface public interface GreetingActivities { @ActivityMethod(name = "greet") String composeGreeting(String greeting, String name); } // --- Workflow implementation --- public static class GreetingWorkflowImpl implements GreetingWorkflow { // Activity stub wired with a 2-second start-to-close timeout private final GreetingActivities activities = Workflow.newActivityStub( GreetingActivities.class, ActivityOptions.newBuilder().setStartToCloseTimeout(Duration.ofSeconds(2)).build()); @Override public String getGreeting(String name) { return activities.composeGreeting("Hello", name); // blocking call } } // --- Activity implementation --- public static class GreetingActivitiesImpl implements GreetingActivities { @Override public String composeGreeting(String greeting, String name) { return greeting + " " + name + "!"; } } // --- Worker + starter (main) --- WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs(); WorkflowClient client = WorkflowClient.newInstance(service); WorkerFactory factory = WorkerFactory.newInstance(client); Worker worker = factory.newWorker("HelloActivityTaskQueue"); worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); worker.registerActivitiesImplementations(new GreetingActivitiesImpl()); factory.start(); GreetingWorkflow workflow = client.newWorkflowStub( GreetingWorkflow.class, WorkflowOptions.newBuilder() .setWorkflowId("HelloActivityWorkflow") .setTaskQueue("HelloActivityTaskQueue") .build()); String result = workflow.getGreeting("World"); // "Hello World!" System.out.println(result); System.exit(0); // Run: ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloActivity ``` -------------------------------- ### Start Caller Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexusmessaging/ondemandpattern/README.md Starts the caller worker process for the Nexus Messaging sample. This worker initiates and manages the remote workflows. ```bash ./gradlew -q :core:execute -PmainClass=io.temporal.samples.nexusmessaging.ondemandpattern.caller.CallerRemoteWorker ``` -------------------------------- ### Execute Temporal Java Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/encodefailures/README.md Command to run the sample application using Gradle. This command specifically executes the Starter class for the encode-failures sample. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.encodefailures.Starter ``` -------------------------------- ### Start Handler Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexusmessaging/ondemandpattern/README.md Starts the handler worker process for the Nexus Messaging sample. This worker listens for and processes workflow tasks. ```bash ./gradlew -q :core:execute -PmainClass=io.temporal.samples.nexusmessaging.ondemandpattern.handler.HandlerWorker ``` -------------------------------- ### Initialize RAG Workflow with Activities and Chat Client Source: https://context7.com/temporalio/samples-java/llms.txt Sets up activity options with timeouts and retries, and initializes the VectorStoreActivity stub and TemporalChatClient for LLM interactions. The chat client is configured with a system prompt to answer questions using only provided context. ```java @WorkflowInit public RagWorkflowImpl() { ActivityOptions opts = ActivityOptions.newBuilder() .setStartToCloseTimeout(Duration.ofMinutes(2)) .setRetryOptions(RetryOptions.newBuilder().setMaximumAttempts(3).build()) .build(); this.vectorStore = Workflow.newActivityStub(VectorStoreActivity.class, opts); ActivityChatModel chatModel = ActivityChatModel.forDefault(); this.chatClient = TemporalChatClient.builder(chatModel) .defaultSystem("Answer questions using only the provided context.") .build(); } ``` -------------------------------- ### Execute Sample Workflows Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/excludefrominterceptor/README.md Run the sample application to observe the exclusion of specific workflows and activities from interceptors. Check the Temporal Web UI and console logs for verification. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.excludefrominterceptor.RunMyWorkflows ``` -------------------------------- ### Execute Custom Change Version Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/customchangeversion/README.md Run the sample using Gradle. This command executes the main class responsible for the custom change version logic. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.customchangeversion.CustomChangeVersionStarter ``` -------------------------------- ### Run Spring AI MCP Sample Source: https://github.com/temporalio/samples-java/blob/main/README.md Execute the Spring AI MCP sample application using Gradle. Ensure you are in the main repository directory. Requires OPENAI_API_KEY environment variable. ```bash ./gradlew :springai:mcp:bootRun ``` -------------------------------- ### Run Spring AI Multi-Model Sample Source: https://github.com/temporalio/samples-java/blob/main/README.md Execute the Spring AI Multi-Model sample application using Gradle. Ensure you are in the main repository directory. Requires OPENAI_API_KEY and ANTHROPIC_API_KEY environment variables. ```bash ./gradlew :springai:multimodel:bootRun ``` -------------------------------- ### Encrypted Workflow Input Example Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/payloadconverter/crypto/README.md This JSON structure represents an example of encrypted workflow input fields as they would appear in the Temporal Web UI. Note the 'salt', 'iv', and 'value' fields for each data point. ```json [ { "name": { "salt": "uZnKfjmFzwYsH6ncZBVgvvmAPTw=", "iv": "0nK++kg8IgtOJFs+gQ/U0A==", "value": "cvXFWXfU8RFKdlWgjrHaog==" }, "age": { "salt": "uZnKfjmFzwYsH6ncZBVgvvmAPTw=", "iv": "0nK++kg8IgtOJFs+gQ/U0A==", "value": "OFA/XDiwep153xZHOECqJA==" }, "approved": { "salt": "uZnKfjmFzwYsH6ncZBVgvvmAPTw=", "iv": "0nK++kg8IgtOJFs+gQ/U0A==", "value": "Tm23RaHHKz2wM56G2Bn6Vw==" } } ] ``` -------------------------------- ### Attach Search Attributes to Workflow Start in Java Source: https://context7.com/temporalio/samples-java/llms.txt Attach typed key-value metadata to a workflow execution at start time for visibility queries. Supported types include String, Int, Double, Bool, Datetime, and Keyword. The search attributes can be read back using DescribeWorkflowExecution. ```java // Attach at workflow start Map attrs = new HashMap<>(); attrs.put("CustomKeywordField", "keys"); attrs.put("CustomIntField", 1); attrs.put("CustomDoubleField", 0.1); attrs.put("CustomBoolField", true); attrs.put("CustomDatetimeField", ZonedDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX"))); WorkflowOptions options = WorkflowOptions.newBuilder() .setWorkflowId("HelloSearchAttributesWorkflow") .setTaskQueue("HelloSearchAttributesTaskQueue") .setSearchAttributes(attrs) .build(); // Read back via DescribeWorkflowExecution DescribeWorkflowExecutionResponse resp = service.blockingStub().describeWorkflowExecution( DescribeWorkflowExecutionRequest.newBuilder() .setNamespace(client.getOptions().getNamespace()) .setExecution(WorkflowExecution.newBuilder().setWorkflowId("HelloSearchAttributesWorkflow").build()) .build()); SearchAttributes sa = resp.getWorkflowExecutionInfo().getSearchAttributes(); String keyword = GlobalDataConverter.get().fromPayload( sa.getIndexedFieldsOrThrow("CustomKeywordField"), String.class, String.class); // "keys" // Run: ./gradlew -q execute -PmainClass=io.temporal.samples.hello.HelloSearchAttributes ``` -------------------------------- ### Run Spring AI RAG Sample Source: https://github.com/temporalio/samples-java/blob/main/README.md Execute the Spring AI RAG sample application using Gradle. Ensure you are in the main repository directory. Requires OPENAI_API_KEY environment variable. ```bash ./gradlew :springai:rag:bootRun ``` -------------------------------- ### Submit Form and Start Workflow via AJAX Source: https://github.com/temporalio/samples-java/blob/main/springboot/src/main/resources/templates/hello.html This JavaScript code handles form submission. It prevents the default form submission, captures first and last names, and sends them as a JSON payload to start a Temporal workflow via an AJAX POST request. The workflow result is then displayed on the page. ```javascript $( "#sampleform" ).submit(function( event ) { event.preventDefault(); var $form = $( this ), firstName = $form.find( "input[name='firstName']" ).val(), lastName = $form.find( "input[name='lastName']" ).val(), url = $form.attr( "action" ); $.ajax({ 'url': url, 'method':'POST', 'dataType': 'json', 'contentType': 'application/json', 'data':JSON.stringify({ "firstName": firstName, "lastName": lastName }), success: function(response) { $( "#result" ).empty().append( response ); } }); }); ``` -------------------------------- ### Request Trip Booking (Client) Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/bookingsyncsaga/README.md Execute this command to request a booking. The booking is expected to fail to demonstrate the compensation flow. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.bookingsyncsaga.TripBookingClient ``` -------------------------------- ### Run EarlyReturnWorker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/earlyreturn/README.md Execute the worker to process workflow tasks. Ensure this is running before starting the client. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.earlyreturn.EarlyReturnWorker ``` -------------------------------- ### Execute Encrypted Payloads Sample Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/keymanagementencryption/awsencryptionsdk/README.md Run the sample application to demonstrate encrypted payloads. Ensure your AWS credentials and key ARN environment variable are set. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.keymanagementencryption.awsencryptionsdk.EncryptedPayloads ``` -------------------------------- ### Access Orders Endpoint Source: https://github.com/temporalio/samples-java/blob/main/springboot/src/main/java/io/temporal/samples/springboot/camel/README.md Navigate to this URL in your browser after the Spring Boot application has started to view the orders. ```bash http://localhost:3030/orders ``` -------------------------------- ### Start Caller Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexusmessaging/callerpattern/README.md Launches the caller worker process. This worker initiates and interacts with the handler workflow. ```bash ./gradlew -q :core:execute -PmainClass=io.temporal.samples.nexusmessaging.callerpattern.caller.CallerWorker ``` -------------------------------- ### Run SpringBoot Sample with Temporal Cloud Profile Source: https://github.com/temporalio/samples-java/blob/main/README.md Execute a Spring Boot sample application with the 'tc' profile activated for Temporal Cloud. This requires editing the application-tc.yaml file first. ```bash ./gradlew bootRun --args="--spring.profiles.active=tc" ``` -------------------------------- ### Run Nexus Handler Worker Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexuscancellation/README.MD Starts the Nexus handler worker. Ensure this is run in a separate terminal. ```bash ./gradlew -q execute -PmainClass=io.temporal.samples.nexuscancellation.handler.HandlerWorker \ --args="-target-host localhost:7233 -namespace my-target-namespace" ``` -------------------------------- ### Create Nexus Endpoint Source: https://github.com/temporalio/samples-java/blob/main/core/src/main/java/io/temporal/samples/nexus/README.MD Creates a Nexus endpoint, specifying the target namespace, task queue, and a description file. ```bash temporal operator nexus endpoint create \ --name my-nexus-endpoint-name \ --target-namespace my-target-namespace \ --target-task-queue my-handler-task-queue \ --description-file ./core/src/main/java/io/temporal/samples/nexus/service/description.md ```