Hi,
I had a similar scenario. I took the following approach.
- I created my own DB table for my CustomWorkItemHandler. i maintained the Session ID, Process Instance ID, WorkItem ID, and state (as needed by you). Everytime the workitemhandler is executed, it will update the DB table . Note that it DOES not complete or abort the work item.
- In my case i had an external event to complete the work item. Upon receipt of the event, i loaded the persisted ksession, then performed a completeWorkitem for the specific work item ID. I got the work item ID as part of the external event.
This is basically how the Human task works. I had picked the idea from there. HumanTask however is much more complex; while this is a much more simple case.