JBPM中 使用JobExecutor執行timer定義的job

Job executor在jbpm.cfg.xml中是被缺省注釋的,所以只要去掉此行即可通過JobExecutor來定時觸發timer中的event-handler了?

Xml代碼

<jbpm-configuration><import resource="jbpm.default.cfg.xml" /><import resource="jbpm.businesscalendar.cfg.xml" /><import resource="jbpm.tx.hibernate.cfg.xml" /><import resource="jbpm.jpdl.cfg.xml" /><import resource="jbpm.bpmn.cfg.xml" /><import resource="jbpm.identity.cfg.xml" /><!-- Job executor is excluded for running the example test cases. --><!-- To enable timers and messages in production use, this should be included. --><import resource="jbpm.jobexecutor.cfg.xml" />
</jbpm-configuration>

測試代碼

/*** @author hzhlu*/
public class CopyOfTimerRepeatTest extends JbpmTestCase {String	deploymentId;protected void setUp() throws Exception {super.setUp();deploymentId = repositoryService.createDeployment().addResourceFromClasspath("org/jbpm/examples/timer/repeat/process.jpdl.xml").deploy();}protected void tearDown() throws Exception {repositoryService.deleteDeploymentCascade(deploymentId);super.tearDown();}public void testTimerRepeat() {ProcessInstance processInstance = executionService.startProcessInstanceByKey("TimerRepeat");// 查詢進入狀態后是否已經建立起timer jobJob job = managementService.createJobQuery().processInstanceId(processInstance.getId()).uniqueResult();System.out.println("job info:" + job.getDueDate() + "  " + job.toString());assertNull(executionService.getVariable(processInstance.getId(), "escalations"));String msg;for (int i = 0; i < 10; i++) {long difference = job.getDueDate().getTime() - System.currentTimeMillis();msg = "Job觸發倒計時: " + difference +   " check escalations:"+ executionService.getVariable(processInstance.getId(), "escalations");System.out.println(">>> " + msg);// 延時1秒try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}}}
}

JPDL 定義文件,3秒鐘后觸發,然后每隔5秒再觸發事件?

XML代碼

<?xml version="1.0" encoding="UTF-8"?><process name="TimerRepeat" xmlns="http://jbpm.org/4.4/jpdl"><start g="19,50,48,48"><transition to="guardedWait" /></start><state name="guardedWait" g="98,46,127,52"><on event="timeout1"><timer duedate="3 seconds" repeat="5 seconds" /><event-listener class="org.jbpm.examples.timer.repeat.Escalate" /></on><transition name="go on" to="next step" g="-16,-17"/></state><state name="next step" g="283,46,83,53"/></process>

事件處理程序?

Java代碼?

public class Escalate implements EventListener {private static final long	serialVersionUID	= 1L;public void notify(EventListenerExecution execution) {System.out.println("Escalate.notify()");Integer escalations = (Integer) execution.getVariable("escalations");if (escalations == null) {execution.setVariable("escalations", 1);} else {execution.setVariable("escalations", escalations + 1);}}
}

執行結果?

job info:2010-07-27 14:55:43.0 timer[9|2010-07-27 14:55:43|timeout1]?

>>> Job觸發倒計時: 2907 check escalations:null?

>>> Job觸發倒計時: 1907 check escalations:null?

>>> Job觸發倒計時: 891 check escalations:null?

Escalate.notify()?

>>> Job觸發倒計時: -109 check escalations:1?

>>> Job觸發倒計時: -1125 check escalations:1?

>>> Job觸發倒計時: -2125 check escalations:1?

>>> Job觸發倒計時: -3125 check escalations:1?

>>> Job觸發倒計時: -4140 check escalations:1?

Escalate.notify()?

>>> Job觸發倒計時: -5140 check escalations:2?

>>> Job觸發倒計時: -6140 check escalations:2?




本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/249395.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/249395.shtml
英文地址,請注明出處:http://en.pswp.cn/news/249395.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

二維碼生成

從vs Nugets搜索ThoughtWorks.QRCode下載ThoughtWorks.QRCode.dll private byte[] CreateQrcode(string code){ string enCodeString code;QRCodeEncoder qrCodeEncoder new QRCodeEncoder();qrCodeEncoder.QRCodeEncodeMode QRCodeEncoder.ENCODE_MODE.BYTE;qrCodeEncod…

vue created

https://blog.csdn.net/xdnloveme/article/details/78035065

Qt打開文件對話框同時選中多個文件或單個文件

Qt中打開單個文件 //str_path為文件路徑 QString str_path QFileDialog::getOpenFileName(this, tr("選擇轉碼文件"), tr("/home"), tr("視頻文件(*.mp4 *.m3u8);;所有文件&#xff08;*.*);;")); 打開多個文件 QString strs; QStringList file…

Activiti Explorer安裝

Activiti Explorer安裝 分類&#xff1a; activiti 2014-05-06 19:11 349人閱讀 評論(0) 收藏 舉報 一、Activiti Explorer介紹 流程引擎的用戶控制臺。使用它來啟動新流程&#xff0c;分配任務&#xff0c;查看并認領任務&#xff0c;等等。這個工具也可以用來管理Activ…

一招明白URL和URI的區別

URL和URI的區別(示例)&#xff1a; URL[統一資源定位器]&#xff1a; http://localhost:8080/api/account/queryAccountInfoURI[統一資源定位符]&#xff1a; /api/account/queryAccountInfo解釋&#xff1a;說白了&#xff0c;可以認為url是絕對路徑&#xff0c;uri是相對路徑…

JS ES6中export和import詳解

1.Export 模塊是獨立的文件&#xff0c;該文件內部的所有的變量外部都無法獲取。如果希望獲取某個變量&#xff0c;必須通過export輸出&#xff0c; // profile.js export var firstName Michael; export var lastName Jackson; export var year 1958;或者用更好的方式&am…

巧用地圖

L1-1 天梯賽座位分配&#xff08;20 分&#xff09; 天梯賽每年有大量參賽隊員&#xff0c;要保證同一所學校的所有隊員都不能相鄰&#xff0c;分配座位就成為一件比較麻煩的事情。為此我們制定如下策略&#xff1a;假設某賽場有 N 所學校參賽&#xff0c;第 i 所學校有 M[i] 支…

Mac系統中MongoChef鏈接MongoDB集群的方法

第一步&#xff1a;啟動Mongochef&#xff0c;點擊鏈接按鈕&#xff1b;第二步&#xff1a;打開連接配置面板&#xff0c;填寫數據庫名&#xff1b;第三步&#xff1a;選擇鏈接類型Connection Type&#xff0c;一般分為直接連接和集群鏈接&#xff0c;這里選擇集群鏈接 Replica…

nginx配置文件nginx.conf

user www www;#指定nginx運行的用戶及用戶組,默認為nobodyworker_processes 8;#開啟的線程數&#xff0c;一般跟邏輯CPU核數一致error_log /alidata/log/nginx/error.log crit; #定位全局錯誤日志文件&#xff0c;級別以notice顯示&#xff0c;還有debug,info,warn,error,crit模…

js 中async

一、終極解決 異步操作是 JavaScript 編程的麻煩事&#xff0c;麻煩到一直有人提出各種各樣的方案&#xff0c;試圖解決這個問題。 從最早的回調函數&#xff0c;到 Promise 對象&#xff0c;再到 Generator 函數&#xff0c;每次都有所改進&#xff0c;但又讓人覺得不徹底。…

Python查找指定文件

在當前目錄以及當前目錄的所有子目錄下查找文件名包含指定字符串的文件&#xff0c;并打印出相對路徑&#xff1a; import os testfiles [] testfilepaths [] L len(os.path.abspath(.))def searchfile(path):for item in os.listdir(path):if os.path.isdir(os.path.join(p…

搭建Mock Server

搭建Mock Server 1.為什么要搭建mock-server&#xff1f; 為了更好的分工合作&#xff0c;讓前端能在不依賴后端環境的情況下進行開發&#xff0c;其中一種手段就是為前端開發者提供一個 web 容器&#xff0c;這個本地環境就是 mock-server。 目前很多前端 mock 數據的方案的…

請問1到10000之前,有多少升數字?(華圖教育面試題)

升數字就是從左向右讀&#xff0c;數值是依次上升的即可&#xff0c;比如123&#xff0c;1256&#xff0c;1389&#xff0c;但是1123&#xff0c;165就不是。以下是我的思路 public static void main(String[] args) {/*** 【請問1到10000之前&#xff0c;有多少升數字&#xf…

crm 一級菜單排序,二級菜單選中并且展開,非菜單權限的歸屬,權限粒度控制到按鈕級別...

排序 /rbac/templatetags/rbac.py from django import template from django.conf import settings import re from collections import OrderedDict register template.Library()register.inclusion_tag(rbac/menu.html) def menu(request):ordered_dictOrderedDict()menu_d…

Maven工程的多模塊

一個大項目需要一個團隊來完成,然后一個大型項目就拆分成幾塊來同時開發,節省時間,提高效率. 大致分為以下幾個模塊(僅是自身經歷): 依賴管理工程模塊:一般現在開發都是以maven來管理jar包,方便.所以整個工程的依賴統一放在一個單獨工程中,一般叫做父工程xxx-parent. 注意事項…

《淺談架構之路:前后端分離模式》

前言&#xff1a;分離模式 對前后端分離研究了一段時間&#xff0c;恰逢公司有一個大項目決定嘗試使用前后端分離模式進行&#xff0c;便參與其中。該項目從2016年初立項至今&#xff0c;平平穩穩得度過&#xff0c;但也涌現出越來越多的問題&#xff0c;絕對不是說前后端分離模…

查詢語句

1.基本查詢語句 1.1 語法&#xff1a; SELECT 屬性列表 FROM 表名或視圖列表 WHERE 條件表達式1 GROUP BY 屬性名1 | HAVING 條件表達式2 ORDER BY 屬性名2 ASC DESC 2.單表查詢 1.應用&#xff1a;查詢表中所有的記錄 2.查詢指定字段&#xff1a;查詢表中所有name字段的記錄 …

Nodejs+Koa2+云服務ECS 開發微信公眾號(一)之環境配置

硬件準備工作 1. 本人采用阿里云的云服務器&#xff0c;購買了入門級云服務ECS&#xff08;293元每年&#xff09;&#xff1b; 2.針對服務器進行認證&#xff0c;設置個人服務器密碼&#xff1b; 3.購買數據盤&#xff0c;并將其掛載于云服務器之上&#xff08;建議掛載在/…

中文詞頻統計與詞云生成

本次作業來源于&#xff1a;https://edu.cnblogs.com/campus/gzcc/GZCC-16SE1/homework/2822 中文詞頻統計 1. 下載一長篇中文小說。 下載長篇小說《西游記》 本次作業小說保存在txt文檔&#xff1a;xyj.txt 2. 從文件讀取待分析文本。 xyj open(rF:/xyj.txt,r,encodingutf-8)…

java SWT Browser實現瀏覽器功能并運行JavaScript代碼

一、創建簡單的瀏覽器 import org.eclipse.swt.*; import org.eclipse.swt.browser.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*;public class Myswt3 {public static void main(String [] args) {Display display new Display();final Shell she…