### Start External Temporal Dev Server Source: https://github.com/temporalio/sdk-java/blob/main/CONTRIBUTING.md Start the Temporal dev server with specific flags, required for running integration tests that the built-in server does not support. Consult CI configuration for necessary flags. ```bash temporal server start-dev --YOUR-FLAGS-HERE ``` -------------------------------- ### Programmatic McpPlugin Setup Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Instantiate McpPlugin programmatically when dependencies are on the classpath and auto-configuration is not desired. ```java new McpPlugin() ``` -------------------------------- ### Workflow Check Analysis Output Example Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/samples/gradle-multi-project/README.md Example output from the `gradlew check` command, indicating workflow analysis results. It shows the number of workflow classes found and details any invalid member accesses, such as using `java.time.LocalTime.now()` which is disallowed. ```text Analyzing classpath for classes with workflow methods... Found 1 class(es) with workflow methods Workflow method io.temporal.workflowcheck.sample.gradlemulti.workflows.MyWorkflowImpl.errorAtNight() (declared on io.temporal.workflowcheck.sample.gradlemulti.workflows.MyWorkflow) has 1 invalid member access: MyWorkflowImpl.java:10 invokes java.time.LocalTime.now() which is configured as invalid ``` -------------------------------- ### Programmatic VectorStorePlugin Setup Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Instantiate VectorStorePlugin programmatically when dependencies are on the classpath and auto-configuration is not desired. ```java new VectorStorePlugin(vectorStore) ``` -------------------------------- ### Install Rosetta on Apple Silicon Source: https://github.com/temporalio/sdk-java/blob/main/CONTRIBUTING.md Install Rosetta, a translation process, on Apple Silicon Macs if required for specific build tools like protoc-gen-rpc-java. This is necessary for builds to complete successfully. ```bash /usr/bin/pgrep oahd ``` ```bash softwareupdate --install-rosetta ``` -------------------------------- ### Run Tests with External Service Source: https://github.com/temporalio/sdk-java/blob/main/CONTRIBUTING.md Execute tests after starting an external Temporal dev server. Ensure the USE_EXTERNAL_SERVICE environment variable is set. ```bash USE_EXTERNAL_SERVICE=true ./gradlew test ``` -------------------------------- ### Specific Method Override Configuration Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md Example showing how to mark a specific method as valid ('false') while all other members of the class are marked as invalid ('true'). ```properties temporal.workflowcheck.invalid.my/package/MyUnsafeClass=true temporal.workflowcheck.invalid.my/package/MyUnsafeClass.safeMethod=false ``` -------------------------------- ### Initialize TemporalChatClient in Workflow Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Example of initializing and configuring TemporalChatClient within a Temporal workflow. Ensure ActivityChatModel is correctly set up and necessary activities/tools are provided. ```java @WorkflowInit public MyWorkflowImpl(String goal) { ActivityChatModel chatModel = ActivityChatModel.forDefault(); WeatherActivity weather = Workflow.newActivityStub(WeatherActivity.class, opts); this.chatClient = TemporalChatClient.builder(chatModel) .defaultSystem("You are a helpful assistant.") .defaultTools(weather, new MyTools()) .build(); } @Override public String run(String goal) { return chatClient.prompt().user(goal).call().content(); } ``` -------------------------------- ### Workflow Check Output Example Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/samples/maven/README.md This is an example of the output you might see when the workflow check identifies an invalid member access. It specifies the workflow method, the class where the invalid access occurs, the line number, and the specific API call that is disallowed. ```text Analyzing classpath for classes with workflow methods... Found 1 class(es) with workflow methods Workflow method io.temporal.workflowcheck.sample.maven.MyWorkflowImpl.errorAtNight() (declared on io.temporal.workflowcheck.sample.maven.MyWorkflow) has 1 invalid member access: MyWorkflowImpl.java:11 invokes java.time.LocalTime.now() which is configured as invalid ``` -------------------------------- ### Example Workflow Check Output Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/samples/gradle/README.md This output shows a typical result from running the Gradle workflow check. It indicates the number of workflow classes found and details specific violations, such as accessing non-deterministic methods like `java.time.LocalTime.now()`. ```text Analyzing classpath for classes with workflow methods... Found 1 class(es) with workflow methods Workflow method io.temporal.workflowcheck.sample.gradle.MyWorkflowImpl.errorAtNight() (declared on io.temporal.workflowcheck.sample.gradle.MyWorkflow) has 1 invalid member access: MyWorkflowImpl.java:10 invokes java.time.LocalTime.now() which is configured as invalid ``` -------------------------------- ### Temporal Workflow Assistant Service Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Example of an Assistant Service implemented as a Temporal Workflow. It uses TemporalChatClient and ActivityChatModel, and replaces plain tools with Temporal activity stubs. ```java @WorkflowInterface interface AssistantWorkflow { @WorkflowMethod String respond(String goal); } class AssistantWorkflowImpl implements AssistantWorkflow { private final ChatClient chatClient; @WorkflowInit AssistantWorkflowImpl(String goal) { WeatherActivity weather = Workflow.newActivityStub(WeatherActivity.class, opts); this.chatClient = TemporalChatClient.builder(ActivityChatModel.forDefault()) .defaultSystem("You are a helpful assistant.") .defaultTools(weather, new MyTools()) .build(); } @Override public String respond(String goal) { return chatClient.prompt().user(goal).call().content(); } } ``` -------------------------------- ### Programmatic EmbeddingModelPlugin Setup Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Instantiate EmbeddingModelPlugin programmatically when dependencies are on the classpath and auto-configuration is not desired. ```java new EmbeddingModelPlugin(embeddingModel) ``` -------------------------------- ### Spring AI Assistant Service (Outside Temporal) Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Example of a standard Spring AI service outside of a Temporal workflow, using ChatClient with default tools. ```java @Service class AssistantService { private final ChatClient chatClient; AssistantService(ChatModel chatModel) { this.chatClient = ChatClient.builder(chatModel) .defaultSystem("You are a helpful assistant.") .defaultTools(new WeatherTools(), new MyTools()) .build(); } String respond(String goal) { return chatClient.prompt().user(goal).call().content(); } } ``` -------------------------------- ### Get Activity Name from Method Reference Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Obtain the activity name using a Kotlin method reference. This provides a type-safe way to reference activities. ```kotlin val activityName = activityName(ActivityInterface::activityMethod) ``` -------------------------------- ### Implement @SideEffectTool for Timestamps Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Create a class annotated with @SideEffectTool to wrap non-deterministic operations like getting the current time. These are recorded in history on first execution. ```java @SideEffectTool public class TimestampTools { @Tool(description = "Get current time") public String now() { return Instant.now().toString(); } } ``` -------------------------------- ### Get Workflow Signal Name from Method Reference Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Determine the workflow signal name by providing a method reference to the signal method. This ensures accurate signal identification. ```kotlin val workflowSignalName = workflowSignalName(WorkflowInterface::signalMethod) ``` -------------------------------- ### Get Workflow Name from Reified Type Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Retrieve the workflow name using a reified generic type parameter. This offers a type-safe approach to identify workflows. ```kotlin val workflowName = workflowName() ``` -------------------------------- ### Customize Temporal Options per Namespace Source: https://github.com/temporalio/sdk-java/blob/main/temporal-spring-boot-autoconfigure/README.md Customize Temporal options for specific namespaces by defining beans that start with the namespace/alias and end with the function class name, followed by 'Customizer'. Auto-registered interceptors are not supported; use WorkerFactoryOptions for customization. ```java // TemporalOptionsCustomizer type beans must start with the namespace/alias you defined and end with function class // name you want to customizer and concat Customizer as the bean name. @Bean TemporalOptionsCustomizer assignWorkflowServiceStubsCustomizer() { return builder -> builder.setKeepAliveTime(Duration.ofHours(1)); } // Data converter is also supported @Bean DataConverter assignDataConverter() { return DataConverter.getDefaultInstance(); } ``` -------------------------------- ### Get Workflow Query Type from Method Reference Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Extract the workflow query type using a method reference to the query method. This aids in type-safe query handling. ```kotlin val workflowQueryType = workflowQueryType(WorkflowInterface::queryMethod) ``` -------------------------------- ### Get Workflow Result with Reified Type Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Use reified generic type parameters with the `getResult` method for type-safe retrieval of workflow results. This avoids the need for explicit Class objects. ```kotlin val workflowResult = workflowStub.getResult>() ``` -------------------------------- ### Build Project Source: https://github.com/temporalio/sdk-java/blob/main/AGENTS.md Performs a clean build of the entire project, including compilation and packaging. ```bash ./gradlew clean build ``` -------------------------------- ### Show Help Text for Workflow Check JAR Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md Run this command to display the help text for the temporal-workflowcheck all-in-one JAR. Replace with the actual version number. ```bash java -jar path/to/temporal-workflowcheck--all.jar --help ``` -------------------------------- ### Format Code with Spotless Source: https://github.com/temporalio/sdk-java/blob/main/AGENTS.md Applies code formatting rules using the Spotless Gradle plugin. Run this before committing to ensure consistent code style. ```bash ./gradlew --offline spotlessApply ``` -------------------------------- ### Run Workflow Check with Configuration Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md This command demonstrates running the workflow check with a custom configuration file. Multiple configuration files can be specified, with later ones overriding earlier ones. The --no-default-config flag prevents the default configuration from being loaded. ```bash java -jar path/to/temporal-workflowcheck--all.jar check --config config/workflow.properties --no-default-config path/to/my.jar ``` -------------------------------- ### Run Temporal Test Server Native-Image via Gradle Source: https://github.com/temporalio/sdk-java/blob/main/temporal-test-server/README.md Executes the Temporal Test Server as a native-image through Gradle. This command assumes the native executable has already been built. ```bash ./gradlew -PnativeBuild :temporal-test-server:nativeRun ``` -------------------------------- ### Running Gradle Workflow Check Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/samples/gradle/README.md Execute the Gradle wrapper to perform workflow checks. This command analyzes the classpath for workflow methods and reports any detected issues. ```bash gradlew check ``` -------------------------------- ### Passing Media by URI vs. Raw Bytes Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Demonstrates the preferred method of passing media by URI and the alternative of using raw bytes, highlighting the size limitations associated with the latter. The URI method is recommended to avoid exceeding payload size limits. ```java // Good — only the URL crosses the activity boundary. Media image = new Media(MimeTypeUtils.IMAGE_PNG, URI.create("https://cdn.example.com/pic.png")); // Works, but size-limited — see below. Media image = new Media(MimeTypeUtils.IMAGE_PNG, new ByteArrayResource(bytes)); ``` -------------------------------- ### Instantiate WorkerFactory with Options DSL Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Use the DSL extension for WorkerFactory to configure its options. This simplifies the instantiation process. ```kotlin val workerFactory = WorkerFactory(workflowClient) { // WorkerFactoryOptions DSL setMaxWorkflowThreadCount(800) setWorkflowCacheSize(800) } ``` -------------------------------- ### Build Native Executable for Temporal Test Server Source: https://github.com/temporalio/sdk-java/blob/main/temporal-test-server/README.md Builds a native executable for the Temporal Test Server using Gradle and GraalVM native-image. The executable will be located at build/graal/temporal-test-server. ```bash ./gradlew -PnativeBuild :temporal-test-server:nativeCompile ``` -------------------------------- ### Check Code Formatting Source: https://github.com/temporalio/sdk-java/blob/main/AGENTS.md Verifies that the code adheres to the defined formatting standards using the Spotless Gradle plugin. This is a required check before merging. ```bash ./gradlew spotlessCheck ``` -------------------------------- ### Instantiate RetryOptions with DSL Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Use the Kotlin DSL to fluently instantiate RetryOptions. This provides a more concise way to configure retry policies. ```kotlin val sourceRetryOptions = RetryOptions { setInitialInterval(Duration.ofMillis(100)) setMaximumInterval(Duration.ofSeconds(1)) setBackoffCoefficient(1.5) setMaximumAttempts(5) } ``` -------------------------------- ### Run All Tests Source: https://github.com/temporalio/sdk-java/blob/main/AGENTS.md Executes all tests within the project. This can be time-consuming. ```bash ./gradlew test ``` -------------------------------- ### Configure Global and Model-Specific Activity Options Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Define a ChatModelActivityOptions bean to manage configuration-driven per-model overrides. The 'default' key acts as a global baseline, while specific model names can override these settings. ```java @Bean ChatModelActivityOptions chatModelActivityOptions() { ActivityOptions fiveMinute = ActivityOptions.newBuilder(ActivityChatModel.defaultActivityOptions()) .setStartToCloseTimeout(Duration.ofMinutes(5)) .build(); return new ChatModelActivityOptions(Map.of( ChatModelTypes.DEFAULT_MODEL_NAME, fiveMinute, // global baseline "claude", ActivityOptions.newBuilder(fiveMinute).setTaskQueue("claude-heavy").build())); // override } ``` -------------------------------- ### Handling Collection Iteration False Positives Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md Demonstrates how to safely iterate over collection entry sets when static analysis might flag them as unsafe. Wrapping the entry set in an ArrayList is a common workaround. ```java import java.util.ArrayList; import java.util.TreeMap; import java.util.Map; var map = new TreeMap<>(Map.of("a", "b")); for (var entry : new ArrayList<>(map.entrySet())) { // ... } ``` -------------------------------- ### Run Workflow Check on JAR or Classes Directory Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md Execute the workflow check command using the all-in-one JAR. Provide paths to your JAR files or class directories as classpath entries. The command accepts optional configuration files and a flag to show valid methods. ```bash java -jar path/to/temporal-workflowcheck--all.jar check path/to/my.jar path/to/my/classes/ ``` -------------------------------- ### Configure Worker with Options DSL Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Apply DSL extensions to configure Worker options, such as setting deadlock detection timeouts. ```kotlin val worker = workerFactory.newWorker("taskQueue") { // WorkerOptions DSL setDefaultDeadlockDetectionTimeout(5000) } ``` -------------------------------- ### Descriptor Pattern Matching Order Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md Illustrates the order in which descriptor patterns are checked for a method call, from most specific to least specific. ```properties java/lang/String.indexOf(Ljava/lang/String;I) java/lang/String.indexOf String.indexOf(Ljava/lang/String;I) String.indexOf indexOf(Ljava/lang/String;I) indexOf String java/lang/String java/lang java ``` -------------------------------- ### Configure ActivityOptions with Nested RetryOptions DSL Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Configure ActivityOptions using a nested DSL for RetryOptions. This allows for complex configurations within a single fluent block. ```kotlin val activityOptions = ActivityOptions { // ActivityOptions DSL setTaskQueue("TestQueue") setStartToCloseTimeout(Duration.ofMinutes(1)) setScheduleToCloseTimeout(Duration.ofHours(1)) setRetryOptions { // Nested RetryOptions DSL setInitialInterval(Duration.ofMillis(100)) setMaximumInterval(Duration.ofSeconds(1)) setBackoffCoefficient(1.5) } } ``` -------------------------------- ### Configure OpenTracing Activity Client Interceptor Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-opentracing/README.md Register the OpenTracingActivityClientInterceptor for standalone Activity Clients. ```java ActivityClientOptions activityClientOptions = ActivityClientOptions.newBuilder() //... .setInterceptors(Collections.singletonList(new OpenTracingActivityClientInterceptor())) .build(); ActivityClient activityClient = ActivityClient.newInstance(service, activityClientOptions); ``` -------------------------------- ### Bridge OpenTelemetry to OpenTracing Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-opentracing/README.md Use OpenTracingShim to create an OpenTracing Tracer compatible with OpenTelemetry. This is useful for OpenTelemetry users needing OpenTracing compatibility. ```java io.opentracing.Tracer tracer = OpenTracingShim.createTracerShim(); //or io.opentracing.Tracer tracer = OpenTracingShim.createTracerShim(openTelemetry); GlobalTracer.registerIfAbsent(tracer); ``` -------------------------------- ### Configure Activity Task Queue Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Use ActivityOptions to set a specific task queue for an activity. This allows for routing activities to dedicated worker pools. ```java ActivityChatModel chatModel = ActivityChatModel.forDefault( ActivityOptions.newBuilder(ActivityChatModel.defaultActivityOptions()) .setTaskQueue("chat-heavy") .build()); ``` -------------------------------- ### Running Workflow Check with Maven Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/samples/maven/README.md Execute this Maven command to run the workflow check as part of the build verification process. This will analyze your project's classpath for workflow classes and report any invalid member accesses. ```bash mvn verify ``` -------------------------------- ### Configure Gradle for Snapshot Releases Source: https://github.com/temporalio/sdk-java/blob/main/README.md Add this repository to your build.gradle file to access snapshot releases of the Temporal Java SDK. Snapshot releases are intended for testing and may not be stable. ```gradle repositories { maven { url "https://central.sonatype.com/repository/maven-snapshots/" } ... ``` -------------------------------- ### Show Valid Workflow Methods Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md Use the --show-valid flag to include valid workflow methods in the output, in addition to the invalid ones. ```bash java -jar path/to/temporal-workflowcheck--all.jar check --show-valid path/to/my.jar ``` -------------------------------- ### Copy and Override RetryOptions Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Utilize the `copy` extension method to create a new RetryOptions instance with modified attributes. This is useful for creating variations of existing configurations. ```kotlin val overriddenRetryOptions = sourceRetryOptions.copy { setInitialInterval(Duration.ofMillis(10)) setMaximumAttempts(10) setDoNotRetry("some-error") } ``` -------------------------------- ### Configure Multiple Temporal Namespaces Source: https://github.com/temporalio/sdk-java/blob/main/temporal-spring-boot-autoconfigure/README.md Define multiple non-root Temporal namespaces in application.yml. Each namespace can have distinct configurations for connection options, registered workflows/activities, and data converters. ```yaml spring.temporal: namespaces: - namespace: assign alias: assign workers-auto-discovery: packages: com.component.temporal.assign workers: - task-queue: global - namespace: unassign alias: unassign workers-auto-discovery: packages: com.component.temporal.unassign workers: - task-queue: global ``` -------------------------------- ### Implement Plain Tool for Data Processing Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Define a plain tool class with @Tool methods. The user is responsible for ensuring determinism by calling activities, side effects, or child workflows. ```java public class MyTools { @Tool(description = "Process data") public String process(String input) { SomeActivity act = Workflow.newActivityStub(SomeActivity.class, opts); return act.doWork(input); } } ``` -------------------------------- ### Run a Single Test Source: https://github.com/temporalio/sdk-java/blob/main/AGENTS.md Executes a single, specific test case identified by its package and class name. The --offline flag ensures no network access is required. ```bash ./gradlew :temporal-sdk:test --offline --tests "" ``` -------------------------------- ### Add Temporal Java SDK Dependency to Gradle Source: https://github.com/temporalio/sdk-java/blob/main/README.md Add this line to your build.gradle file to include the Temporal Java SDK in your Gradle project. Ensure 'N.N.N' is replaced with the correct version. ```gradle compile group: 'io.temporal', name: 'temporal-sdk', version: 'N.N.N' ``` -------------------------------- ### Configure Maven for Snapshot Releases Source: https://github.com/temporalio/sdk-java/blob/main/README.md Add this repository configuration to your pom.xml to enable fetching snapshot releases of the Temporal Java SDK. Snapshot releases are useful for testing development features but do not have the same stability guarantees as official releases. ```xml oss-sonatype oss-sonatype https://central.sonatype.com/repository/maven-snapshots/ true ``` -------------------------------- ### Run Temporal Test Server Tests with Tracing Agent Source: https://github.com/temporalio/sdk-java/blob/main/temporal-test-server/README.md Executes the tests for the Temporal Test Server with the GraalVM tracing agent enabled for native-image compilation. This is used to generate metadata for the native-image. ```bash ./gradlew -Pagent -PnativeBuild :temporal-test-server:test ``` -------------------------------- ### Add temporal-testing Dependency to build.gradle Source: https://github.com/temporalio/sdk-java/blob/main/temporal-testing/README.md Add this line to your build.gradle file to include the Temporal testing utilities. ```gradle testImplementation("io.temporal:temporal-testing:N.N.N") ``` -------------------------------- ### Copy Metadata from Test Run for GraalVM Source: https://github.com/temporalio/sdk-java/blob/main/temporal-test-server/README.md Copies the metadata generated from a test run to be used by GraalVM native-image compilation. This command is typically run after executing tests with the tracing agent. ```bash ./gradlew -PnativeBuild :temporal-test-server:metadataCopy --task test ``` -------------------------------- ### Run Specific Core SDK Tests Source: https://github.com/temporalio/sdk-java/blob/main/AGENTS.md Executes tests specifically for the core SDK module, filtering by workflow package. The --offline flag ensures no network access is required. ```bash ./gradlew :temporal-sdk:test --offline --tests "io.temporal.workflow.*" ``` -------------------------------- ### Run Specific Tests with Gradle Source: https://github.com/temporalio/sdk-java/blob/main/CONTRIBUTING.md Filter and run specific tests or groups of tests using Gradle. The --tests flag allows targeting individual classes or package patterns. The --offline flag can be used to prevent Gradle from accessing the network. ```bash ./gradlew :temporal-sdk:test --offline --tests "io.temporal.activity.ActivityPauseTest" ``` ```bash ./gradlew :temporal-sdk:test --offline --tests "io.temporal.workflow.*" ``` -------------------------------- ### Add JUnit4 or JUnit5 Extensions to build.gradle Source: https://github.com/temporalio/sdk-java/blob/main/temporal-testing/README.md To use JUnit4 or JUnit5 extensions for testing, add the specified capabilities to your build.gradle configuration. ```gradle testImplementation("io.temporal:temporal-testing:N.N.N") { capabilities { requireCapability("io.temporal:temporal-testing-junit4") //requireCapability("io.temporal:temporal-testing-junit5") } } ``` -------------------------------- ### Add temporal-testing Dependency to pom.xml Source: https://github.com/temporalio/sdk-java/blob/main/temporal-testing/README.md Include this dependency in your pom.xml to use the Temporal testing utilities. ```xml io.temporal temporal-testing N.N.N ``` -------------------------------- ### Configure OpenTracing Client Interceptor Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-opentracing/README.md Register the OpenTracingClientInterceptor when building WorkflowClientOptions. ```java WorkflowClientOptions.newBuilder() //... .setInterceptors(new OpenTracingClientInterceptor()) .build(); ``` -------------------------------- ### Define Temporal Activity Stub for Weather Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Define an interface for a Temporal Activity that can be called from a workflow. Annotate with @ActivityInterface and @Tool. ```java @ActivityInterface public interface WeatherActivity { @Tool(description = "Get weather for a city") @ActivityMethod String getWeather(String city); } ``` -------------------------------- ### Programmatic Workflow Check Execution Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md Instantiate the WorkflowCheck class with a Config object and use findWorkflowClasses to analyze classpath entries programmatically. This returns details about all found workflow method implementations, including any invalid aspects. ```java import io.temporal.workflowcheck.WorkflowCheck; import io.temporal.workflowcheck.Config; // ... Config config = Config.newBuilder().build(); // Or load from properties file WorkflowCheck workflowCheck = new WorkflowCheck(config); workflowCheck.findWorkflowClasses("path/to/my.jar", "path/to/my/classes/"); ``` -------------------------------- ### Inject WorkflowClient Instances by Namespace Source: https://github.com/temporalio/sdk-java/blob/main/temporal-spring-boot-autoconfigure/README.md Autowire different WorkflowClient instances from various namespaces using the @Resource annotation with a bean name corresponding to the namespace alias plus 'WorkflowClient'. The primary root namespace client is injected without a specific name. ```java // temporalWorkflowClient is the primary and rootNamespace bean. @Resource WorkflowClient workflowClient; // Bean name here corresponds to the namespace/alias + Simple Class Name @Resource(name = "assignWorkflowClient") private WorkflowClient assignWorkflowClient; @Resource(name = "unassignWorkflowClient") private WorkflowClient unassignWorkflowClient; ``` -------------------------------- ### Add Temporal Java SDK Dependency to Maven Source: https://github.com/temporalio/sdk-java/blob/main/README.md Include this dependency in your pom.xml to add the Temporal Java SDK to your Maven project. Replace 'N.N.N' with the desired version. ```xml io.temporal temporal-sdk N.N.N ``` -------------------------------- ### Making a Default Disallowed Method Valid Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md Overrides the default configuration to make a specific method, like Thread.getId(), valid for use within Temporal. ```properties temporal.workflowcheck.invalid.java/lang/Thread.getId=false ``` -------------------------------- ### Add temporal-spring-ai Maven Dependency Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-spring-ai/README.md Include this dependency in your Maven project to use the Temporal Spring AI integration. ```xml io.temporal temporal-spring-ai ${temporal-sdk.version} ``` -------------------------------- ### Configure OpenTracing Worker Interceptor Source: https://github.com/temporalio/sdk-java/blob/main/contrib/temporal-opentracing/README.md Register the OpenTracingWorkerInterceptor when building WorkerFactoryOptions. ```java WorkerFactoryOptions.newBuilder() //... .setWorkerInterceptors(new OpenTracingWorkerInterceptor()) .build(); ``` -------------------------------- ### Add temporal-kotlin Dependency Source: https://github.com/temporalio/sdk-java/blob/main/temporal-kotlin/README.md Include the temporal-kotlin module as a dependency in your Maven or Gradle project. ```xml io.temporal temporal-kotlin N.N.N ``` ```gradle compile group: 'io.temporal', name: 'temporal-kotlin', version: 'N.N.N' ``` -------------------------------- ### Workflowcheck Invalid Member Configuration Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md Defines a pattern for an invalid member (method or field) within a specific class or package. Set to 'true' to mark as invalid, 'false' to mark as valid. ```properties temporal.workflowcheck.invalid.[[some/package/]ClassName.]memberName[(Lmethod/Descriptor;)V]=true|false ``` -------------------------------- ### Suppress Warnings with @WorkflowCheck.SuppressWarnings Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md Use the `@WorkflowCheck.SuppressWarnings` annotation to ignore errors in specific methods. This annotation is retained in bytecode, unlike the standard Java `@SuppressWarnings`. ```java import io.temporal.workflowcheck.WorkflowCheck; @WorkflowCheck.SuppressWarnings public long getCurrentMillis() { return System.currentTimeMillis(); } ``` ```java import io.temporal.workflowcheck.WorkflowCheck; @WorkflowCheck.SuppressWarnings(invalidMembers = "currentTimeMillis") public long getCurrentMillis() { return System.currentTimeMillis(); } ``` -------------------------------- ### Inline Warning Suppression with WorkflowCheck.suppressWarnings Source: https://github.com/temporalio/sdk-java/blob/main/temporal-workflowcheck/README.md This method provides inline suppression but is discouraged due to bytecode evaluation order and runtime dependency. Use annotations instead. ```java import io.temporal.workflowcheck.WorkflowCheck; public long getCurrentMillis() { WorkflowCheck.suppressWarnings("currentTimeMillis"); var l = System.currentTimeMillis(); WorkflowCheck.restoreWarnings(); return l; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.