深入分析iMatrix平臺流程引擎之業務補償
阿新 • • 發佈:2020-10-22
流程屬性中的業務補償:
自己認為業務補償也是屬於事件的。
1 xml中的配置
<process … … ……>
… … … …
<extend>
… … … …
<expiation-setting>
<set-type>http</set-type>
<delete-instance>
/expense-report/delete-instance-expiation.htm
</delete-instance>
<cancel-instance>
/expense-report/cancel-instance-expiation.htm
</cancel-instance>
<task-jump>/expense-report/task-jump-expiation.htm</task-jump>
<pause-instance/>
<continue-instance/>
<goback-task/>
</expiation-setting>
</extend>
… … … …
</process>
任務退回配置的是
spring bean名稱,該
bean需要實現的介面為
com.norteksoft.wf.engine.client.ReturnTaskInterface。當在流程監控中刪除、取消、暫停、繼續例項時,做法基本一致,如下:
首先獲得
xml中配置的請求方式和請求的
url;當請求方式是
HTTP方式時,使用
httpclient請求
url;當請求方式是
RESTful方式時,使用的是
Jersey的
Client請求的。
WebUtil.java中的兩種請求方式實現如下:
/**
* 普通的
http請求
*
@param url
*/
public
static
voidgetHttpConnection(String url,Long companyId,LongentityId,String systemCode){
String resultUrl=SystemUrls.
getBusinessPath(systemCode);
if(PropUtils.
isBasicSystem(resultUrl)){
resultUrl = SystemUrls.
getSystemUrl("imatrix");
}
log.info(" == systemurl : ["+resultUrl+"] == ");
resultUrl = resultUrl + url+"?companyId="+companyId+"&entityId="+entityId;
log.info(" == restleturl : ["+resultUrl+"] == ");
HttpGet httpget =
newHttpGet(resultUrl);
HttpClient httpclient =
newDefaultHttpClient();
ResponseHandler<String> responseHandler =
newBasicResponseHandler();
try{
httpclient.execute(httpget, responseHandler);
}
catch(ClientProtocolException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
httpclient.getConnectionManager().shutdown();
}
/** * RESTful請求 * @paramurl * @paramcompanyId */ public static voidrestful(String url,Long companyId,Long entityId,StringsystemCode){ ClientConfig config = newDefaultClientConfig(); Client client = Client. create(config); String resultUrl = SystemUrls. getSystemUrl(systemCode); if(PropUtils. isBasicSystem(resultUrl)){ resultUrl = SystemUrls. getSystemUrl("imatrix"); } log.info(" == systemurl : ["+resultUrl+"] == "); resultUrl = resultUrl + url; log.info(" == restleturl : ["+resultUrl+"] == "); WebResource service = client.resource(resultUrl); ClientResponse cr = service .entity("companyId="+companyId+"&entityId="+entityId, MEDIA_TYPE) .accept( MEDIA_TYPE) .post(ClientResponse. class); if(cr != null) log.info("=========== RESTful execute result : ["+cr.getEntity(String. class)+"]=========== ");
/** * RESTful請求 * @paramurl * @paramcompanyId */ public static voidrestful(String url,Long companyId,Long entityId,StringsystemCode){ ClientConfig config = newDefaultClientConfig(); Client client = Client. create(config); String resultUrl = SystemUrls. getSystemUrl(systemCode); if(PropUtils. isBasicSystem(resultUrl)){ resultUrl = SystemUrls. getSystemUrl("imatrix"); } log.info(" == systemurl : ["+resultUrl+"] == "); resultUrl = resultUrl + url; log.info(" == restleturl : ["+resultUrl+"] == "); WebResource service = client.resource(resultUrl); ClientResponse cr = service .entity("companyId="+companyId+"&entityId="+entityId, MEDIA_TYPE) .accept( MEDIA_TYPE) .post(ClientResponse. class); if(cr != null) log.info("=========== RESTful execute result : ["+cr.getEntity(String. class)+"]=========== ");
}
Demo演示登入地址:http://demo.imatrix.net.cn:8888/imatrix
iMatrix平臺原始碼下載地址:https://github.com/norteksoft/5.2.1.RC
如有使用問題請登入iMatrix平臺論壇諮詢:http://bbs.imatrix.net.cn/forum.php?mod=forumdisplay&fid=37
轉載於:https://my.oschina.net/imatrix/blog/157227