Zeebeclient not fetching active jobs

i use this version implementation(“io.camunda:spring-boot-starter-camunda-sdk:8.6.11”)
with my springboot app
but i face issue when i use zeebeclient to get active jobs (user tasks as service to can deal with zeebeclient)
when i defined a worker it can pick jobs and get info
but when i use zeebclient to get active jobs get empty list

Hi @khalidnouh, welcome to the forums! Can you share your code?

what the best practise if i’m using camunda 8.6+ as i want to handle users tasks (assign, unassign and complete ) tottaly from backend (springboot app)
for now i use them as service task and job worker to listen and store in db
then i can manipulate by using my code
what you think?

@khalidnouh - the job worker method for user tasks is deprecated. It will be replaced by user task listeners in a future release (I believe they are scheduled for 8.8, but I admit I am not 100% sure).

But still not clear on what you mean that a worker gets jobs but Zeebe client doesn’t. The Zeebe client creates the job workers. Are you trying to query active jobs with the client? Can you share your code?

here my code for worker that get the job

  @JobWorker(type = "MANUAL_REVIEW", maxJobsActive = 5, requestTimeout = 10000)
    fun handleManualReviewJob(client: JobClient, job: ActivatedJob) {
        logger.info("Received new user task - JobId: ${job.key}, ProcessInstanceKey: ${job.processInstanceKey}")
        try {
            val activeJob = handleJobSaving(job)
            logger.info("Stored active job in database - JobId: ${job.key}, ProcessInstanceKey: ${job.processInstanceKey}")
        } catch (ex: Exception) {
            logger.error("Failed to store active job - JobId: ${job.key}", ex.message)
        }
    }

after that i can deal with jobs fully controlled like this below

fun completeTask(jobId: Long, processInstanceKey: Long, variables: Map<String, Any>): Boolean {
        logger.info("Attempting to complete task - JobId: $jobId, ProcessInstanceKey: $processInstanceKey")

        val activeJob = activeJobService.getJobByIdAndProcessInstance(jobId, processInstanceKey)

        return if (activeJob != null) {
            activeJob.status = JobStatus.COMPLETED
            activeJob.assignmentStatus = AssignmentStatus.DONE
            activeJob.variablesJson = objectMapper.writeValueAsString(variables)
            activeJob.updatedAt = LocalDateTime.now()
            activeJobService.updateActiveJob(activeJob)

            zeebeClient.newCompleteCommand(activeJob.jobId)
                .variables(variables)
                .send()
                .join()

so what you think about this ?
actually i need fully control for tasks from backend , and will be custom ui for this so need it to be fully managed by backend
i appreciate your inputb


this my simple workflow

Hi @khalidnouh - I think a better pattern might be to pass the variables to your handler and complete the task within the worker:

(pseudo-code, I don’t know Kotlin syntax!!)

@JobWorker(type = "MANUAL_REVIEW", maxJobsActive = 5, requestTimeout = 10000)
    fun handleManualReviewJob(client: JobClient, job: ActivatedJob) {
        logger.info("Received new user task - JobId: ${job.key}, ProcessInstanceKey: ${job.processInstanceKey}")
        try {
            val variables = job.getVariablesAsType(VariableClass::class)
            val activeJob = handleJobSaving(variables)
            logger.info("Stored active job in database - JobId: ${job.key}, ProcessInstanceKey: ${job.processInstanceKey}")
            completeTask(client, job)
        } catch (ex: Exception) {
            logger.error("Failed to store active job - JobId: ${job.key}", ex.message)
        }
    }

fun completeTask(client: JobClient, activeJob: ActivatedJob, variables: Map<String, Any>): Boolean {
        logger.info("Attempting to complete task - JobId: $job.getKey(), ProcessInstanceKey: $processInstanceKey")
   activeJob.status = JobStatus.COMPLETED
            activeJob.assignmentStatus = AssignmentStatus.DONE
            activeJob.variablesJson = objectMapper.writeValueAsString(variables)
            activeJob.updatedAt = LocalDateTime.now()
            activeJobService.updateActiveJob(activeJob)

            zeebeClient.newCompleteCommand(activeJob.jobId)
                .variables(variables)
                .send()
                .join()

From a software development best practices standpoint, you already have the job and the client, so you don’t need to instantiate a new instance of the Zeebe client or fetch the job again. The handler shouldn’t care about the job itself, just the data that the job contains.

I don’t have the full context for what you want to do, but you can certainly use the APIs to build your own task application frontend that gives you full control over the lifecycle while still keeping all the benefits of the Camunda platform.

1 Like

yes this what i do , but i don’t want to complete task in worker , i need to be fully controlled from our custom ui and backend
so the worker will make some actions due to db , then handle completion later by api calls from frontend
so this may cause issues in the future ?

@nathan.loding also if i want to assign a user task from backend , how i can do this
tasklist api is deprecated and when i try zeepe api not works i got not found

also if i use 8.6 or 8.8 there is an enhancements regarding user tasks and handling as i prefer fully control from back end

regarding what you said before
the job worker method for user tasks is deprecated. It will be replaced by user task listeners in a future release (I believe they are scheduled for 8.8, but I admit I am not 100% sure).
what i can use for now for the user tasks to be fully managed from backend assign and complete …

@khalidnouh - I admit, I’m not sure what you’re actually asking for. There are many different ways to structure your application and workflows, and Camunda is flexible enough to accommodate all of them. What way works best for your requirements, I cannot say.

If you want the task pushed immediately to your application, then you need to use job workers now and plan for user task listeners in the future. If you search the forum, there are many threads about job workers for user tasks. If the immediacy isn’t a concern, then you might consider polling the API at certain intervals to fetch the data.

The Tasklist REST API is deprecated but will not be removed in the next release, so you can still use it. If you want to use the unified REST API, that is still an alpha feature and needs to be enabled.

Alternately, you don’t have to use a user task in your process. You could make it a REST connector that sends a request to your API, and then have the process wait for a message from your application before continuing. There are a nearly infinite number of ways to model and run this. Based on what’s been shared here I feel pretty confident in saying that Camunda supports whatever design you need, so I would focus on designing your workflows and understanding when and where the integrations need to happen, then figuring out the integration.

i can’t use connectors as our solution is custom as end user can design his own workflow based on predefined config,
for the tasklist it will be deprecated but for now some operations not supported so i can’t use it for assign task as exapmle,
so if i use zeepi api will handle my tasks from backend (i use camunda 8.6.11)
if so how i can configure in my local cluster
thanks

@khalidnouh - the existing (not alpha) APIs should cover all the operations you need. What operations are not supported?

To enable the unified API, you need to enable alpha features by setting CAMUNDA_REST_QUERY_ENABLED to true (or camunda.rest.query.enabled if you are using Helm) (docs ref)


this is the issue with me , i need a solution for assigning , i appreciate your support

@khalidnouh - apologies, there’s some confusion here. Let me try to clarify!

There are two types of user tasks in Camunda:

  • Zeebe user tasks, which are the new standard and will be the only option in the future. The lifecycle of these tasks is managed by Zeebe, not Tasklist, so you can’t use the Tasklist API for lifecycle actions.
  • Job worker user tasks, which were the original way user tasks worked within Camunda. These are now deprecated, and will be removed in a future release. These user tasks only work with the Tasklist API.

Because you had mentioned using job workers, I assumed you were using job worker user tasks. I should have clarified earlier, apologies!

The link in the screenshot (also linked below) gives details on using Zeebe user tasks. For your questions:

  • To assign a user, you need to use this endpoint. This endpoint should be available without enabling alpha features.
  • To query Zeebe user tasks, you can use the deprecated Tasklist API, or you need to enable the alpha query endpoints mentioned in a previous reply. The query APIs are quite stable at this point, so my personal recommendation is to enable them and begin developing against them.
  • You cannot use a job worker to fetch Zeebe user tasks, you will need to user task listeners which are, unfortunately, still in development at this time.

Hope that helps clarify!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.