简体   繁体   中英

Jbpm6 . Asynchronous workitem and retry

Let me come directly to use case.

I am having a number of work-items in my process say A,B,C . It starts in A--->B--->C order.

In my case, B is a call to a 3rd party web service. C should process only if B is success. if the call to the web-service fails, system should retry after 5 min . The number of retries are limited to 3 .

How can I achieve this using Jbpm6 .?

Some options that I understand from doc are,

1) I can use a work item handler. Inside work item, I will start another thread which will do the retries and finally it calls the completeWrokItem() method. But in this case my process engine thread will wait unnecessarily for the completeWrokItem() call. 2)I can use command for retry . But if I call command it will execute in another thread and the process thread will execute C . Which is not a desirable way

How can I create a process so that, B will execute in back-end and will notify the engine that it can continue executing C ?

Please advice.

Thanks in advance.

Please comment if my question is not clear enough to answer.

Your question is not completely clear; however, I provide an answer to hopefully provide some clarity:

  1. For asynchronous execution, you should follow guidelines in documentation: JBMP 6.0 Async Documentation

  2. Given your processes flow, if you use a Command and a process defined as: A->B->C; C will not start until the command completes.

  3. To have commands run in parallel, you use parallel branches. In below pic, if Script1 and Script2 were commands they would execute in parallel, and Email would only execute once both Scripts complete: 并行执行

  4. A command signals complete by simply returning from execute method:

     public ExecutionResults execute(CommandContext ctx) throws Exception { // Set results if exist. Otherwise, return empty ExecutionResults. ExecutionResults results = new ExecutionResults(); // This would match the name of an output parameter for the work item. // results.setData("result", "result data"); logger.info("Command finished execution: " + this.getClass()); logger.debug("Results of executing command: ", results); return results; } 

    `

Add a XOR gateway after the node B, Add script to of the node B and set the status and retry_count of web-service(if success, status_b = true; if failed, status_b = false and retry_count ++),

XOR go to C if the retry_count>=3 or status_b == true else go to B again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM