How to consume microservice or any other service in handle method

Hi Team,

How to consume micro service or any other service in handle method.Below is the sample code…getValidationJob(); is the restTemplate method i need to consume…

@ZeebeWorker(type = “dailynightjob”)
public void handleDailynightjob(final JobClient jobClient, final ActivatedJob activatedJob) {
JobDetailsEntity jde = activatedJob.getVariablesAsType(JobDetailsEntity.class);
dailyJobs.forEach(x -> {
final Map<String, Object> result = new HashMap<>();
result.put(“jobType”, x.getJobType());
System.out.println(" ----dailynightvalidationjobexecution - key - jobType - result : " + result);
client.newCompleteCommand(key).variables(result).send().join();

	});

Please help me …also share github repository related to spring boot zeebe with consuming rest or other services

thanks
rk.

@Ramakrishna I do not fully understand your question. You want to consume external services from inside a worker? You can use normal Java to do that. Before calling client.newCompleteCommand(key).variables(result).send().join(); you execute your logic that might involve calling another REST service or any other Service that you want.

You can split the work that you want to do like this:

Where inside the worker I am calling another method that can do the external service request, storing data in a database or whatever you need to do. How you do those things is more a Spring Boot question, and it is not related to zeebe at all.

1 Like

Thank you @salaboy

It is more useful to me.

thanks
rk.

@Ramakrishna can you please mark the question as answered?
Thanks