Temporal Java SDK with Spring Boot

Connect a Spring Boot service to Temporal with the official temporal-spring-boot-starter, covering connection settings, worker registration, interceptors, testing and placement of workers inside existing services.

On this page

How Temporal Java SDK with Spring Boot connects existing Spring services to Temporal

A Java team with Spring services that needs durable workflows does not have to build a separate runtime to get started. The supported method is the io.temporal:temporal-spring-boot-starter dependency, which covers connecting to the Temporal Service, configuring workers, adding interceptors and testing. The starter lets your existing Spring Boot application act as a Temporal client and host the workers that execute your workflow and activity code, so the work fits into services your team already builds, deploys and monitors. Before you add the dependency, confirm the Spring Boot and Java versions your starter release supports in the Temporal Java SDK documentation, since those constraints decide which services can host workers without a platform upgrade.

Workers can run inside an existing Spring service, but that choice has consequences. A worker that shares a JVM with a request-serving API competes with that API for memory, CPU and thread pools, and a deployment that restarts the API also restarts the worker. Decide early whether each service will host only the workers for its own task queues, or whether a dedicated worker service will run them. Also decide which Spring service owns each workflow type, because the task queue names and registered workflow implementations need to match across every deployment that polls them. Plan these choices with your platform team before the first production deployment.

The Temporal Service itself is separate from the Spring application. You will either run it yourself or use Temporal Cloud, and each path has its own decisions for networking, identity, persistence and upgrades. The Spring starter only needs the address, namespace and credentials of the service it connects to, so the application code can stay the same across both options. Treat the service design as a separate project with its own scope, owners and review. Confirm with your security team which network path, certificate chain and identity provider the workers will use, because those settings are required before the Spring services can reach the Temporal Service in any environment.

What a Spring Boot team needs before adding the starter

The starter is the easy part. Before adding temporal-spring-boot-starter to a Spring service, the team needs to settle which Temporal Service it talks to, which Java and Spring Boot versions the chosen SDK release supports, and how the application reaches the service securely. Each card below is one item to confirm before the first worker starts.

Choose the Temporal Service target

Decide whether the application connects to a self-hosted Temporal Service or to Temporal Cloud. This choice sets the connection target, the namespace the application uses, and who operates upgrades. For self-hosted, confirm the server version against the official upgrade and compatibility documentation, since the server must be supported by the SDK release you pick. Ask who owns the namespace and whether separate namespaces exist for each environment.

Self-hosted deployment docs

Confirm Java and Spring Boot versions

Each SDK release lists the Java and Spring Boot versions it supports, and the starter follows that matrix. Check the SDK release notes for the Java runtime, the Spring Boot major and minor line, and any build tool requirements before you pin versions in your build file. Do not assume that the latest Spring Boot line is covered. Confirm the exact pairing in the official Java SDK documentation and record it in your architecture decision record.

Spring Boot integration docs

Verify network reachability

Workers and clients in the Spring application must reach the Temporal frontend endpoint over the network, usually on the gRPC port the service exposes. Map the path from each application pod, VM or host to the frontend, including firewalls, load balancers, service mesh policy and DNS. The Temporal deployment guidance expects services on hosts that are not reachable from the public internet, so the application's network zone and the Temporal network must be planned together.

Prepare TLS and certificate material

If the Temporal Service requires mTLS or TLS on the frontend, the Spring application needs client certificates, private keys and a trust chain in a format the SDK accepts. Decide where these come from (a corporate certificate authority, a secrets manager or the platform) and who rotates them. Confirm the certificate subject and server name checks with the service owner before configuring the connection, because mismatches usually surface only at worker startup.

Self-hosted security docs

Plan authorization and namespace access

If no Authorizer is configured on a self-hosted service, it uses a noop Authorizer that allows every API request with no authentication. Before the starter connects, confirm that the service enforces authentication and that the application's identity has the namespace role it needs. Ask whether the application uses a dedicated credential, how that credential is stored in Spring configuration, and how it is rotated without a restart.

Security controls docs

Agree on worker placement

Decide whether workers run inside existing Spring services, in separate worker deployments, or both. Running workers in a web service couples their scaling and restarts to request traffic, while separate deployments add an operational unit to own. Confirm which task queues each application instance polls, how many instances run per environment, and who receives alerts when a worker stops polling.

Configuration sequence for the Spring Boot starter

This sequence takes a Spring service from no Temporal code to a running worker that polls its task queue and completes a test workflow. Each step ends with a check so the team can confirm the connection, registration and interceptors before building business workflows on top.

  1. Add the starter dependency to the build

    The service team adds the io.temporal:temporal-spring-boot-starter dependency to the existing Maven or Gradle build, matching the Temporal Java SDK version the rest of the platform uses. Confirm the version with the SDK release notes and keep it aligned with the Temporal Service version you plan to run. The step is done when the application compiles and the dependency tree shows the starter and its SDK modules resolved without conflicts with existing Spring or gRPC libraries.

  2. Set connection properties for the Temporal Service

    Engineers set the target address and namespace in the Spring configuration files, typically per environment, and keep TLS and API credentials in the secrets store your organization already uses rather than in source control. Confirm with the platform team which namespace each environment uses and whether the frontend requires mTLS or an API key. The step is done when the application starts and logs a successful connection to the Temporal Service at startup, with no connection errors in the first minute.

  3. Annotate workflow and activity implementations

    Developers mark each workflow interface implementation and activity implementation as a Spring bean and apply the SDK annotations so the starter discovers them during startup. Keep workflow code deterministic, since the starter registers it exactly as written and replay depends on it. The step is done when the application context loads and the startup log or an actuator view lists each workflow type and activity type under the intended task queue.

  4. Configure worker options per task queue

    The team defines worker settings for each task queue, such as the queue name, the number of workflow and activity threads, and any concurrency limits, in the Spring configuration. Map each queue to the workflows and activities it should serve so that one service does not accidentally poll a queue another team owns. Confirm the chosen values with the team that operates the Temporal Service, because limits on one worker affect load on the whole queue. The step is done when each configured worker shows as polling its task queue in the Temporal Web UI or in the metrics your team exports.

  5. Wire interceptors into clients and workers

    Developers register any client or worker interceptors as Spring beans so the starter applies them to every client and worker it creates. Typical uses are tracing, logging and auth headers, and each interceptor should be reviewed for side effects, since it runs on every workflow and activity call. The step is done when a test call produces the expected trace span or log line and the auth header reaches the Temporal Service, which the team confirms in its tracing backend or request logs.

  6. Run a test workflow end to end

    The team runs a small test workflow that calls one activity on the configured task queue, using the Spring test support or a non-production namespace. Use the time-skipping test server for fast feedback where the team has chosen it, and confirm the same path against a real Temporal Service before release. The step is done when the test workflow reaches the completed state, the activity result is returned to the caller, and the run appears in the Web UI under the expected namespace and queue.

How auto-registered workers behave inside a Spring context

The starter scans the Spring context for beans that carry Temporal annotations and registers them as workflow and activity implementations on workers it creates, so the team does not write worker registration code by hand. Beans without the expected annotations are not registered, and a missing annotation fails quietly unless someone checks. Before building on this, confirm on the Temporal Java SDK Spring Boot integration page which annotations are scanned, which task queues the starter creates by default, and how workers are named and configured. Worker lifecycle is tied to the Spring application context: workers start as the context starts and stop as it closes. Confirm when polling begins relative to database pools, HTTP listeners and other beans that activities depend on, because an activity that needs a bean still initializing will fail and retry.

Spring closes beans in reverse dependency order, so the shutdown sequence decides whether in-flight work finishes cleanly. The team should verify that each worker stops polling before the resources its activities use, such as data sources, message clients and HTTP clients, are closed. Check the graceful shutdown behavior the SDK documents for in-flight activity tasks, including how long a worker waits before forcing the stop. An activity still running when the window closes is handed back to the Temporal Service and retried elsewhere, so activities that touch external systems must be idempotent or use idempotency keys. Test this with a deliberate restart during a long activity in a non-production environment and record what happened to the activity and the workflow history.

Where workers should run in an existing Spring estate

Running workers in the same process or deployment as the web tier is the smallest change to an existing Spring service. The application starts the Temporal starter alongside its controllers, registers its workflow and activity implementations, and polls task queues from the same pods that serve HTTP traffic. There is one artifact, one release pipeline and one set of configuration values to keep in step.

  • Scaling: Worker capacity grows only when web capacity grows, so a spike in HTTP traffic adds polling workers you may not need, and a backlog of activities cannot be scaled without scaling the web tier too.
  • Deployment coupling: Every release of a workflow or activity is also a release of the web tier, and a bad worker change can roll back user-facing features.
  • Resource isolation: Long-running CPU or memory work in an activity competes with request threads in the same JVM, which can raise latency for users.
  • Shutdown behavior: Pods stopped for a web deployment also stop polling, so in-flight activities need enough time to finish or be retried on another worker.

Before choosing this placement, confirm with your platform team how pod termination grace periods and rolling updates are configured, and test a deployment while workflows are running.

Mapping Spring configuration to Temporal settings

This table maps Spring properties and bean types to the Temporal concepts they control, and shows which values change per environment and which must match between the client and the worker. Read it before splitting a service into a starter-side client and a separate worker process, because a mismatch in namespace or task queue fails silently.

Spring setting or beanTemporal conceptEnvironment or match rule
Service address property (target or connection settings)Frontend address the client and workers dialEnvironment-specific. Point dev, test and production at different Temporal Services and confirm the address and TLS settings in your environment.
Namespace propertyNamespace that isolates workflow and task queue dataMust match exactly between the client that starts workflows and every worker that runs them.
Task queue name in worker configurationQueue that workers poll for workflow and activity tasksMust match the queue named in the workflow start options. A typo produces tasks no worker picks up.
Workflow interface and implementation beansWorkflow type registered with a workerWorkers register the implementation. Clients call the interface, so keep the interface package shared between both.
Activity bean (annotated implementation)Activity types a worker can executeRegister on the worker that owns the task queue. Activity options such as timeouts are set per call, not in this bean.
Worker concurrency and poller settingsNumber of workflow and activity tasks a worker runs in parallelSet per worker process. Tune per deployment size, and confirm the defaults for your starter version.
Interceptor beansClient or worker interceptors that wrap calls for tracing, logging or auth headersRegister on the side that makes or handles the call. A client-only interceptor does not run on worker-side execution.
Client bean for starting workflowsConnection to the Temporal Service used to start, signal and queryRuns in the calling service. It does not need a worker, but it needs the same namespace as the workers.
Credentials and TLS propertiesIdentity and transport the client presents to the Temporal ServiceEnvironment-specific and secret. Load from your secret store, and confirm the authorization setup on self-hosted servers.

Securing the connection and the workflow data

A Spring service that starts workflows or runs workers touches three things: the connection to the Temporal Service, the identity it presents, and the data inside workflow inputs and results. Each card below covers one of these controls and the check to run before the connection reaches production.

Encrypt the connection to the service

Worker and client traffic to the Temporal Service should run over TLS, and the Spring connection settings must point at the certificate chain your platform team issues. Check that the application trusts only that chain and that certificate rotation does not require a code change. Confirm with your platform team whether the service also requires mTLS from clients, since the server-side settings for frontend and internode traffic are separate.

Self-hosted security docs

Do not run without an Authorizer

If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. A Spring service that connects to such a cluster can start, signal, or terminate any workflow in any namespace it can reach. Before go-live, confirm that the server has an Authorizer and a ClaimMapper in place, and test that a client without the right role is refused.

Scope access to namespaces

Each Spring application should use the namespace that belongs to its team or product, and the credentials it presents should grant roles only in that namespace. Mapping JWT or certificate claims to namespace roles keeps one service from reading another team's workflow histories. Review the namespace and role mapping with the platform owner whenever a new worker or client is added.

Keep secrets out of code

Temporal client certificates, OIDC or API credentials, and codec keys belong in Spring configuration sources such as environment variables, externally managed property sources, or a secrets manager that injects them at startup. Do not place them in application.yml committed to source control or in workflow code. Confirm that logs and the Spring actuator endpoints do not print these values.

Encrypt payloads with a custom codec

Temporal stores workflow inputs, results and activity data in its history, so sensitive fields such as account identifiers or personal data are visible to anyone with read access to the event history. A custom payload codec, configured on the Spring client and workers, encrypts these payloads before they leave the process. Decide which data classes need encryption, define key rotation, and plan a codec server only if your team needs it for the Web UI.

Verify the controls end to end

Test the connection after each configuration change: a connection with no certificate, a client with a wrong namespace role, and a payload read from the history viewer should each fail or show ciphertext. Record the results with the change so auditors can trace the control. Ask your Temporal operator for a copy of the server's security settings so the application and server tests cover the same design.

How a Spring request starts a workflow and reaches a worker

The request starts at a Spring controller that uses the Temporal workflow client to start a workflow execution on the Temporal Service, which records it and places tasks on a task queue. A worker running inside the same Spring service polls that queue, executes workflow code, and hands side-effecting calls to activities that reach downstream systems. The boundary to check is the path from the application network to the Temporal Service, because the self-hosted service should sit on trusted internal networks only and its frontend access is controlled by the Authorizer you configure.

Request path from a Spring controller through the Temporal Service to an activity.

Testing workflows and activities in a Spring project

Split tests for a Spring-based Temporal application into two layers before writing the first one. The unit layer runs workflow code against mocked activities, so it checks sequencing, branching, retry handling and how the workflow reacts to failures without touching a Temporal Service. The integration layer runs the same workflow and activity beans in a Spring test context against the Temporal test server, so it checks that the workers, activity options, task queues and serialization are wired correctly. Keep the mocks for the unit layer only, because a mocked activity cannot reveal a wrong task queue name or a configuration key that never reaches the worker.

In practice, start the Spring test context with the same configuration classes the production service uses, then override only the connection to the Temporal Service so tests point at the in-memory test server. Confirm with the Java SDK documentation how the test server is started and how time skipping behaves in your version, since a workflow that sleeps for days should finish in test time only if that feature is active. Use @SpringBootTest slices sparingly, because a context that loads every bean slows the suite, while a context that loads too little hides misconfigured workers. Decide early which bean properties are overridden in tests and record them in one place.

Keep replay and versioning checks out of this suite. Those checks need real event histories exported from a running namespace and compare new workflow code against them, so they belong in a separate testing workflow that runs in CI before each deployment. Also confirm with your team whether the integration tests need a running self-hosted or Temporal Cloud namespace for anything beyond the test server, since that changes where the suite runs and who can run it.

Common failures when Spring and Temporal are combined

This table pairs each common failure with its likely cause, a fix and a check you can run in your own environment. Read it when workers sit idle, clients cannot connect, or startup and test runs behave unexpectedly. Most of these failures trace back to a mismatch between the worker configuration and the Temporal Service it points at.

SymptomLikely causeFix and check
Workflows start but no worker picks them upTask queue name or namespace in the worker config differs from the client that starts the workflowCompare the namespace and task queue values in the client and worker properties. Confirm the worker appears in the task queue's poller list in the Web UI or tooling.
Client reports connection refused or deadline exceededWrong frontend address or port in the connection settings for the Temporal ServiceSet the frontend address explicitly and test reachability from the Spring host with a network check to that host and port. Confirm the address is the frontend service, not the Web UI.
TLS handshake or certificate errors at startupTLS enabled on one side only, or a client certificate or CA that does not match the serverCheck that TLS settings match the server's configuration on both ends. Confirm the CA bundle and certificate chain load from the paths in your deployed configuration.
Worker throws errors or retries while the Service is still startingSpring context starts workers before the Temporal Service is reachableConfirm the Service is healthy before the application starts, or allow the application to retry startup. Check worker logs for repeated connection attempts during the first minutes after deployment.
Duplicate worker or bean registration errors in testsMultiple Spring contexts or test classes each register workers on the same task queue or bean namesUse one test context per configuration, or disable auto-registration in tests that create their own workers. Confirm only one worker bean exists per task queue in the test context.
Worker threads stall and tasks time outBlocking calls such as synchronous HTTP, JDBC or sleeps inside activities that occupy the worker's executor threadsMove blocking I/O to bounded activity executors, set activity concurrency limits and keep workflow code free of I/O. Check thread dumps and the schedule-to-start latency metric during load.
Workflows fail with non-determinism after a deploymentWorkflow code changed in a way that alters command order, without versioningRun replay tests against recorded histories in CI before deployment. Confirm the change is wrapped in a versioning mechanism or that no running workflows use the old code path.

Questions teams ask before adding Temporal to Spring

How much effort does adding the Temporal Spring Boot starter take?

For a single service, the starter itself is a small change: you add the io.temporal:temporal-spring-boot-starter dependency and configure the connection to the Temporal Service. The effort grows with the work around it. The number of workflows and activities, how many Spring services will host workers, how your existing Spring configuration handles beans and profiles, and your security requirements for TLS, authentication and secrets all add design and testing time. Whether the Temporal Service is already running matters most of all. If a shared, operated service exists, your team mainly builds workflows. If it does not, deploying and securing the service is a separate project, covered on other pages in this group.

How long does a first Temporal integration in Spring usually take?

A first integration usually moves from a proof of concept to a production design in stages, and the total depends on scope rather than on the starter. A team that already knows Spring and has a reachable Temporal Service can get one workflow running in a test environment fairly quickly. Production readiness takes longer because it includes worker deployment, timeouts and retry policies, workflow versioning, interceptors for logging and tracing, and tests that run before each release. Ask any partner to tie its estimate to a named list of workflows, the services that will run workers, and the environments you need.

What skills and access does the team need for this work?

The work needs three things. First, Java and Spring skills: dependency injection, configuration properties, and the lifecycle of Spring beans, since workers are registered through Spring. Second, Temporal knowledge: the difference between workflows and activities, deterministic workflow code, and how task queues connect clients to workers. Third, access: credentials and network routes to the Temporal Service in each environment, a build pipeline that can run tests, and test environments that resemble production. Security reviewers will also need to see how connection settings and certificates are stored and rotated.

Can an internal team add Temporal to Spring on its own?

Many internal teams can, especially when they already run Spring services and have engineers who have built background job systems before. The risk is less in the first workflow than in the decisions that are hard to change later: how workflows are versioned, which data goes into payloads, how workers scale and shut down, and how tests catch non-determinism before deployment. Teams that want the design reviewed, or that need the work finished to a documented compliance standard, often ask a partner to review the design or to build alongside them. Decide this by comparing your team's Temporal experience with how many services and workflows will depend on the result.

What does a DeployOpen engagement cover for Temporal with Spring?

DeployOpen works on open-source platforms inside your own infrastructure, and most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. For this topic, a scoped engagement can cover reviewing the Spring integration design, configuring the connection to the Temporal Service, setting up workers inside the Spring services you choose, adding interceptors and tests, and documenting how the setup runs. Whether a self-hosted Temporal Service is included depends on the written scope. A quote follows from that scope, and DeployOpen does not publish a price list.

What costs are one-time and what costs recur with Temporal?

One-time costs are the design, the first integration, the test suite and the initial rollout of workers. Recurring costs are the running Temporal Service, its database and visibility store, the compute for your Spring worker services, monitoring, and the staff time for upgrades. Upgrades matter here: Temporal documents that its server should be upgraded one minor version at a time, so plan that work as a recurring activity. If you choose Temporal Cloud instead of self-hosting, its pay-as-you-go pricing starts at 50 US dollars per million actions with active storage at 0.042 dollars per GB-hour and retained storage at 0.00105 dollars per GB-hour, according to the Temporal Cloud pricing page. Confirm current rates and what counts as an action before you budget.

What decides whether workers run inside existing Spring services?

Running workers inside an existing Spring service is common, and it is simpler to operate when the worker's load is modest and its deployment can be scaled apart from the web tier. Check three things first: whether the service's startup and shutdown behavior will wait for workers to finish, whether its memory and CPU limits leave room for workflow and activity work, and whether the same service must handle both HTTP traffic and long-running tasks. If any answer is unclear, a separate worker deployment usually gives you more control over scaling and rollout, and the starter supports that pattern as well.

How DeployOpen scopes and delivers the Spring Boot integration

DeployOpen plans and delivers Temporal Java SDK with Spring Boot work as a written, fixed-scope engagement. The scope fixes which Spring services run workers, how the Temporal connection is configured for each environment, and what testing and handover the client receives.

How we scope

  • Inventory the Spring services that will start workers, call workflows, or both, and record their deployment targets.
  • Agree how the io.temporal:temporal-spring-boot-starter dependency and connection settings are managed per environment.
  • Define which interceptors, worker task queues and test layers are in the written scope and which are excluded.

How we build

  • Configure the starter's connection settings and auto-registered workers against your existing Spring Boot application configuration.
  • Implement interceptors for logging, tracing or auth headers where the agreed scope requires them.
  • Build integration tests for workflows and activities alongside the existing Spring test suite before any worker runs in shared environments.

How we hand over

  • Deliver the configuration, dependency and worker layout as code in your repositories, with a written record of each decision.
  • Document how to start, stop and scale workers inside each Spring service, and which task queues each one serves.
  • Walk your engineers through the test suite and the checks to run before changing workflow or activity code.

How we support

  • Ongoing support, upgrades of the starter and continuous testing are available as a retainer after handover.
  • Changes to scope, such as adding services or new interceptors, are quoted as written changes to the agreed scope.
  • Confirm with your team which Temporal Service option, self-hosted or Temporal Cloud, the Spring services will connect to before scoping.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.