Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config global job category #3735

Closed
hoaxvo16 opened this issue Sep 14, 2023 · 4 comments
Closed

Config global job category #3735

hoaxvo16 opened this issue Sep 14, 2023 · 4 comments

Comments

@hoaxvo16
Copy link

Problem

I have two engines, and I want to create a job category for each engine. As I read the code, I noticed that the JobService only allows querying jobs by category and does not support querying by tenant ID. Therefore, I added a configuration:

 config.addEnabledJobCategory(tenantId);

to SpringProcessEngineConfiguration But it doesn't work. As I delved deeper into the code, I discovered that there were two instances of the JobUtil class being used to create new Job objects:

org.flowable.engine.impl.util.JobUtil

and

org.flowable.cmmn.engine.impl.util.JobUtil

And the way it creates a job is by utilizing the extension element named 'jobCategory' of the BPMN modell:

 protected static JobEntity createJob(VariableContainer variableContainer, BaseElement baseElement, String jobHandlerType, CmmnEngineConfiguration cmmnEngineConfiguration) {
        JobService jobService = cmmnEngineConfiguration.getJobServiceConfiguration().getJobService();
        JobEntity job = jobService.createJob();

        job.setJobHandlerType(jobHandlerType);
        job.setScopeType(ScopeTypes.CMMN);
        job.setElementId(baseElement.getId());
        if (baseElement instanceof CaseElement) {
            job.setElementName(((CaseElement) baseElement).getName());
        }

        List<ExtensionElement> jobCategoryElements = baseElement.getExtensionElements().get("jobCategory");
        if (jobCategoryElements != null && jobCategoryElements.size() > 0) {
            ExtensionElement jobCategoryElement = jobCategoryElements.get(0);
            if (StringUtils.isNotEmpty(jobCategoryElement.getElementText())) {
                Expression categoryExpression = cmmnEngineConfiguration.getExpressionManager().createExpression(jobCategoryElement.getElementText());
                Object categoryValue = categoryExpression.getValue(variableContainer);
                if (categoryValue != null) {
                    job.setCategory(categoryValue.toString());
                }
            }
        }


        job.setTenantId(variableContainer.getTenantId());

        return job;
    }

I have to add the following XML snippet in every BPMN node:

<flowable:jobCategory>myJobCategory</flowable:jobCategory>

My question is, is there any way to configure the engine to create jobs with a single category using a global configuration?

@nhatanh2996
Copy link

+1 need approve it

@nhatanh2996
Copy link

same issue at PR#3734

@tijsrademakers
Copy link
Contributor

No there is currently no global configuration to set a single category, it needs to be set for all BPMN elements where needed.

@hoaxvo16
Copy link
Author

@tijsrademakers is there anyway to config two engine using the same db schema and each engine manage it own jobs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants