Migrate existing Microservice to using Temporal

Hi Team

We have some Microservice written in Spring Boot. Each of them are using a lot of java native API like UUID.randomUUID, CompletableFuture, ThreadPoolExecutor… Now, I need to do some POC with Temporal, but I found some recommendation about we cannot use java native, but instead we need use Temporal API Recommend .

Call Workflow.sleep instead of Thread.sleep

Use Promise and CompletablePromise instead of Future and CompletableFuture

But we cannot replace all exist java native API by Temporal API all at once. My plan is we will migrate some new function to use Temporal (only new function have Workflow, Activity… ) while old function (API) in that Microservice still using java native, and of course all of them are located in same Microservice projet.

Does this have any effect?

Hi @nofear
these constraints apply to workflow code only, not activity code.
You could for example start converting your existing functions to activities, and write a workflow that orchestrates their invocations. Note that in activities you can call any existing code so yes this migration does not have to happen all at once as you mentioned.

In the case where other services that utilize the ones you are writing also use Temporal they can invoke your activities in their workflows rater than having to go through some existing rest apis for example. In addition those other services can be written in different programming languages that Temporal has SDKs for, see polyglot examples here and here.

1 Like