I would say that you should implement the logic of iterating over the applications in your flow service. However, I don’t quite understand your ‘createApplication’ service… does it only creates or does it sends the application out too (I am assuming application to be some kind of a message here)? If the createApplication sends the application out- then yes, you should reprocess the applications already out, but otherwise, there shouldn’t be a problem in re doing the applications from the begining.
Anyway… here’s an example that I am gonna use to explain how I would achieve the ‘resume from last processed’.
Let’s say my service (createApplication) is ‘applyInterest’ that applies month-end interest to the saving bank accounts. It get’s the account record of the account holders from the database, ordered by account number and loops over them. Based on the data of each account record, the service calculates the interest and posts it to the account (updates the database). In this scenario, I could use the startTransaction, commitTransaction and rollbackTransaction services to achieve that the interest gets applied to all the accounts or none, but I do not know how feasible is it in your case, so I would go to the alternative -
My service does the following:
- Register a repo store and tries to retrieve a value against key ‘AccountNumber’.
- If the value is null, form a query ‘Select AccNo, X,Y,Z… order by AccNo’, else form a query ‘Select AccNo, X, Y, X from Table Where AccNo>=AccountNumber (fetched from repo) order by AccNo’
- Execute the query.
- Loop over the result set.
- Save (overwrite) the AccNo from result into the repo (pub.storage:add).
- Process the record - ie calculate the interest and apply it to the account.
This way, even if your service fails while processing an account and you resubmit the step from WmMonitor, it should resume after the last account successfully processed. Of course, if your server crashes after you have processed one and before saving the next AccNo in the store, there still can be duplicate processing. I do not kow if this is doable in your scenario - but its just an approach. Also, there might be a lot of ifs and buts, which will need to be answered based on your business case.
Hope this helps. Rohit
#webMethods-BPMS#webMethods#BPM