cancel
Showing results for 
Search instead for 
Did you mean: 

Using BPM for Form Validation?

mxc4
Champ in-the-making
Champ in-the-making
Hi all,

I am new to using a  workflow engine and just trying to get a handle on the use cases that best suit using one and when to use plain old server side validation in the service layer. I see a tendency for business people to want to abstract out the form validation into task . i.e does this customer exist in the database, do they exist on external systems etc.

One the one hand this is great as it introduces flexibility into the validation process but it makes the coding for providing synchronous user feedback a bit more involved. If the process is inherently asynchronous, like requiring user approval etc, then workflow is great but if the user is filling out a form and can get feedback immediately it not so great.

My current knowledge of activiti is that the process is asynchronous. Once the process has been started you return to your code and then need to "poll" the process for progress. (If there is something I am missing please let me know Smiley Happy ) It seems difficult to get the status of the process in an easy way. i.e have we reached an end or wait state? What is that state? Then using that info to decide what to show the user next. This is from the service layer and not inside the activiti process itself. Currently I need to use processInstance,00 Historyservice, task query etc to get this status. If the process take several seconds then I need to put the thread to sleep and check again till a wait/end state is reached.

Can someone please explain how to do this the right way? I am pretty sure its my limted experience with workflow concepts that is inhibiting my approach to using activiti.

thanks
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
You're current knowledge about activiti being asynchronous (by default) is wrong. When you start a process (or complete a task), the current thread is used to execute the next steps of the process, until another wait-state (task, receive-task, …) or process-end is reached.

So in case you're process has a service-task (some Java behavior) that checks against a 3rd-pary system, after a user-task, the call to our "taskService.complete()" will only return, after that call has been done. If you throw an exception in the service-task that contacts the 3rd party system, this will bubble up to the point where the API-call (completeTask()) is done. On that moment, you can inspect the exception and give the user appropriate feedback (e.g. entity X does not exist in system Y).

Asynchronous behavior is possible in Activiti, but this needs to be explicit ally configured on a per-activity-basis…