Fairly new to JBPM, using latest version of 6.2. I am trying to establish a process by which I can make a calls to a REST API for a legacy platform whenever certain (custom) task types are opened and again via an asynch process when they are completed at some point in the future.
At a high level the process should be something like:
Legacy App -> (REST) JBPM "StartProcess" -> (REST) Legacy App "Task A Created"
Legacy App -> (REST) JBPM "Complete Task A" -> (REST) Legacy App "Task A Completed" & Legacy App (REST) "Task B Created"
I have created and registered a ProcessEventListener and have created a hook in the AfterNodeTriggered event to make a call for nodes of a certain type. I have also created a custom WorkItem definition and added parameters which I can access in my registered WorkItemHandler. The issue I have is that I need my ProcessEventListener to retrieve a unique ID per instance (from the Legacy App) of my WorkItem and attach it to that WorkItem prior to the WorkItemHander being invoked. I can do this in the WorkItemHandler while completing the WorkItem by accessing the getParameter('key'), but I cannot determine how (or if this is possible) in a ProcessEventListener.
Can (and how do) I :
- Get access to parameters of a workItem (or a User Task) in a ProcessEventListener
- Determine the Node Type (e.g. MyCustomTask vs. "User Task") in the ProcessEventListener so that this service call is only invoked for MyCustomTask. I can get the Node 'event.getNodeInstance().getNode()' but I cannot tell what the node type is.
- Prevent my CustomTask from being created if there is any error on the remote service (roll back to the triggering node?).
I am fairly certain the answer is that I should be doing both of these requests in the WorkItemHandler using abortWorkItem() as necessary, but I cannot determine how I handle the corresponding asynch process as part of a WorkItemHandler solution.
Appreciate any feedback in advance!