DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Python Asyncio: Understanding Concurrency With a Scraper
  • Every Acquisition Promises One Company. Most Deliver Two.
  • Every Generation Fears the Machine. How Does the AI Job Panic End?
  • Why Your GPU Fleet Is Both Full and Idle: Building a Capacity Orchestration Layer

Trending

  • When RabbitMQ Accepts a Message but Does Not Route It to a Queue
  • Idempotent Consumers: Preventing Stale Retries With Version-Fenced Writes
  • Choosing a BBD Framework
  • Introducing TypeSafe Jev: Typed Judgments as Programming Primitives

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Culture and Methodologies
  3. Career Development
  4. Use of Priority and Priority Ranges in Camunda Jobs

Use of Priority and Priority Ranges in Camunda Jobs

Learn how to make use of priority and priority ranges in Camunda jobs.

By 
Alok Singh
·
Updated Sep. 19, 22 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
5.5K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

In this topic, will learn how to make use of priority and priority ranges in Camunda jobs and, how it gives us a way to run jobs on different Camunda job executors based on the job’s priority.

Software Requirement

  1. Spring Boot
  2. Camunda 7.16 +
  3. Eclipse or any other IDE
  4. Maven

Implementation of Job With Setting Priority

If you have not created a project with spring boot with embedded Camunda engine, then go through the link and create one.

Next, modify the process.BPMN is given below.

Create a job by setting its priority as below. In this, the timer is created with a priority set to 10.

Create a job by setting its priority

OR copy the below content and save it as “jobs.BPMN” to create this model.

XML
 
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_0fr9mxs" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.1.0">
  <bpmn:process id="camunda-new-features-test-process" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1" name="Start">
      <bpmn:outgoing>Flow_1ql0hfr</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_1ql0hfr" sourceRef="StartEvent_1" targetRef="Event_1hgijag" />
    <bpmn:sequenceFlow id="Flow_0nvdacn" sourceRef="Event_1hgijag" targetRef="Activity_0ocues6" />
    <bpmn:endEvent id="Event_0ptn8u4" name="End">
      <bpmn:incoming>Flow_0pjpitl</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_0pjpitl" sourceRef="Activity_0ocues6" targetRef="Event_0ptn8u4" />
    <bpmn:scriptTask id="Activity_0ocues6" name="Job executed Message" scriptFormat="Groovy">
      <bpmn:incoming>Flow_0nvdacn</bpmn:incoming>
      <bpmn:outgoing>Flow_0pjpitl</bpmn:outgoing>
      <bpmn:script>println("Job executed");</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:intermediateCatchEvent id="Event_1hgijag" name="Check Job Priority" camunda:jobPriority="10">
      <bpmn:incoming>Flow_1ql0hfr</bpmn:incoming>
      <bpmn:outgoing>Flow_0nvdacn</bpmn:outgoing>
      <bpmn:timerEventDefinition id="TimerEventDefinition_1yg78j8">
        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT5S</bpmn:timeDuration>
      </bpmn:timerEventDefinition>
    </bpmn:intermediateCatchEvent>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="camunda-new-features-test-process">
      <bpmndi:BPMNEdge id="Flow_1ql0hfr_di" bpmnElement="Flow_1ql0hfr">
        <di:waypoint x="215" y="117" />
        <di:waypoint x="272" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0nvdacn_di" bpmnElement="Flow_0nvdacn">
        <di:waypoint x="308" y="117" />
        <di:waypoint x="370" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0pjpitl_di" bpmnElement="Flow_0pjpitl">
        <di:waypoint x="470" y="117" />
        <di:waypoint x="532" y="117" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="99" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="185" y="142" width="25" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_0ptn8u4_di" bpmnElement="Event_0ptn8u4">
        <dc:Bounds x="532" y="99" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="540" y="142" width="20" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_0o251cr_di" bpmnElement="Activity_0ocues6">
        <dc:Bounds x="370" y="77" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_025t7qu_di" bpmnElement="Event_1hgijag">
        <dc:Bounds x="272" y="99" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="246" y="142" width="90" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>


Execute Attempt-1: Run the project and open the task list to start the process instance. You can verify that the timer job is executed and the message “Job executed” is prompted on the IDE console which confirms that the job is executed.

Execute Attempt-2: Next, let us modify the properties so that the job executor can pick the jobs based on defined priority, and by doing that we will restrict the job executor to not pick the job.

Add below properties in the application.yaml.

YAML
 
camunda:
  bpm:
    generic-properties:
      properties:
        jobExecutorPriorityRangeMin: 0
        jobExecutorPriorityRangeMax: 9


This will set the job executor to run the jobs whose priority falls between the range 0 to 9 (Both numbers are inclusive) and run the application again.

Points To Note

  1. This is useful in separating multiple types of jobs across multiple process engines.
  2. Allows running job executors in multiple process engines to share the load.
  3. While defining the range, avoid missing and overlapping the range across process engines. For example, if given 2 process engines defined range as 0-9 and 15-20, then jobs with priority 10-14 will never get picked up by job executors.
Camunda career

Opinions expressed by DZone contributors are their own.

Related

  • Python Asyncio: Understanding Concurrency With a Scraper
  • Every Acquisition Promises One Company. Most Deliver Two.
  • Every Generation Fears the Machine. How Does the AI Job Panic End?
  • Why Your GPU Fleet Is Both Full and Idle: Building a Capacity Orchestration Layer

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook