Hi Everyone,
I have a job worker to initialize the process variable but that is not working as expected.
Sometimes worker getting invoked and sometimes not. Below are my usecase with logs.
Worker code: 
    @JobWorker(type = WorkerName.LOAD_URLS, fetchAllVariables = true,name = "loadUrls")
	public Map<String, Object> connectorURLs(final JobClient jobClient, final ActivatedJob activatedJob) {
		log.info("Worker:{} has been started.", WorkerName.LOAD_URLS);
		Map<String, Object> variables = activatedJob.getVariablesAsMap();
		variables.put("test", 1234);
		
		log.info("New variables:{}", variables);
		return variables;
	}
Console log: 
Now, you can the log label "New variables and Worker has not been printed in console.
Any help would be highly appreciated.
TIA.
             
            
              
            
           
          
            
            
              Hi, @yadav1990  Welcome to the forum , you need to use  client.newCompleteCommand(activatedJob.getKey()).variables(variables).send();  instead of  return variables;
Docs: Handle variables as POJO | Camunda Platform 8 Docs 
             
            
              
            
           
          
            
            
              I had tried with that also but didn’t worked.And as per camunda docs autoComplete command is true by default.
             
            
              
            
           
          
            
            
              Is this a different issue that your other thread ?
If you set the variables with SetVariables, can you see them in Tasklist?
             
            
              
            
           
          
          
            
            
              
@JobWorker (type = WorkerName.LOAD_URLS, fetchAllVariables = true,name = “loadUrls”)
 
Hi @yadav1990  . 
Please make sure that the WorkerName.LOAD_URLS  constant value is loadUrls as you mention in process model. The name attribute of JobWorker annotation is not type.
             
            
              
            
           
          
            
            
              I understand your concern and the naming conventioned already taken care.
public static final String LOAD_URLS = "loadUrls";
 
            
              
            
           
          
            
            
              @yadav1990  Please provide the code and process model you tested.
             
            
              
            
           
          
            
            
              yes, this is different issue with jobWorker.And variables can be seen only if jobWorker executed successfully.
             
            
              
            
           
          
            
            
              Code can’t be shared. But the usecase is to call the jobworker first to initialized some process variables and then call the connector. And the code which I have shared above is for jobWorkers.
             
            
              
            
           
          
            
              
                jwulf  
              
                  
                    June 13, 2023, 12:18am
                   
                  11 
               
             
            
              If the job worker handler is not being invoked there are a few potential causes, including:
Job worker not running 
Job worker not connected to broker 
Job worker subscribed (polling for) wrong task type 
 
             
            
              
            
           
          
            
            
              @jwulf  I appreciate you on above points but not agreed completely. Please find my inline answered for above points.
Job worker not running => On application startup I can see the mentioned jobWorker activated in console log and also executing intermittently.
 
Job worker not connected to broker => If jobWorker not connected then how application is running executing other flow like connector and script task.
 
Job worker subscribed (polling for) wrong task type => jobWorker is subscribed for serviceTask and it’s working intermittently.
 
 
Below is the code for our jobWorker 
@Component
 @Slf4j
 public class VariablesInitializer {
 
     /**
      * This methods to set all the microservice urls and tokens
      * 
      * @param jobClient
      * @param activatedJob
      **/
     @JobWorker(type = WorkerName.LOAD_URLS, fetchAllVariables = true,name = "loadUrls")
     public Map<String, Object> connectorURLs(final JobClient jobClient, final ActivatedJob activatedJob) {
         log.info("Worker:{} has been started.", WorkerName.LOAD_URLS);
 
         Map<String, Object> variables = activatedJob.getVariablesAsMap();
         variables.put("test", 1234);
         log.info("New variables:{}", variables);
         return variables;
     }
}
 
            
              
            
           
          
            
            
              @lzgabel  . This is our code snnipet.
@Component
 @Slf4j
 public class VariablesInitializer {
 
     /**
      * This methods to set all the microservice urls and tokens
      * 
      * @param jobClient
      * @param activatedJob
      **/
     @JobWorker(type = WorkerName.LOAD_URLS, fetchAllVariables = true,name = "loadUrls")
     public Map<String, Object> connectorURLs(final JobClient jobClient, final ActivatedJob activatedJob) {
         log.info("Worker:{} has been started.", WorkerName.LOAD_URLS);
 
         Map<String, Object> variables = activatedJob.getVariablesAsMap();
         variables.put("test", 1234);
         log.info("New variables:{}", variables);
         return variables;
     }
}
 
            
              
            
           
          
            
            
              @jwulf  any finding on this issue?
TIA.
             
            
              
            
           
          
            
            
              
 yadav1990:
 
Code can’t be shared.
 
 
Can you build/share a minimal reproducible example?  (eg. Worker doesn’t actually do anything, it just writes to the log and returns)
Asking the community (not Camunda) to try to sort this out without any way for us to try see what you’re seeing, makes it really difficult.