Zdenek Hrib [
https://community.jboss.org/people/zdenek.hrib] created the discussion
"Re: Using jBPM as state machine engine - is it a good idea?"
To view the discussion, visit:
https://community.jboss.org/message/778800#778800
--------------------------------------------------------------
my "system" is basically a simple JBoss EAR, exposing basic CRUD operations for
one entity through JAX-WS and using JPA to store the entities and Envers for auditing
I originally wanted to:
1. store the state of the record only on one place - OK, I guess that the state name could
be actually stored in the jBPM tables and not my original tables, but for the other values
of the record I would still use my original tables (I will treat the BLOB in the jBPM
tables as just a temporary variable storage)
2. trigger the rules evaluation and "next step transition" immediatelly after
the entity update - I could call the jBPM engine in the web service bean
"update" operation
3. have access to the record data (both old and new version) in the rules so I could
decide about the state change - I can feed the already running process with these
variables during the call of jBPM in the web service bean "update" operation
4. the old records to have their running processes immediatelly after upgrading the system
to jBPM enabled version - hm, I guess I would have to miss this, but it is not a big deal
5. have the envers data audit to include the state changes - hm, I could try to merge the
the data audit trail and the jBPM state audit trail somewhere in the user interface
So I guess if I can do something like this in the web service bean operations, then it
would be quite simple:
CREATE operation:
ProcessInstance process = definition.startNewInstance("mydefinition.process",
newRecord); //use the values of the created record as starting point including standard
process data peristence into jBPM tables
newRecord = somehowGetTheUpdatedValuesOfTheNewRecord(); //as it could have been updated
inside the process rules
newRecord.setProcessId(process.getProcessId());
storeIntoDatabase(newRecord);
UPDATE operation:
RecordUpdateEvent event = new RecordUpdateEvent();
event.setOldRecord(originalRecord);
event.setNewRecord(newRecord);
signalEventToTheRunningProcess(originalRecord.getProcessId(), event)/ / do the transition
and if there are rules then decide by the record values including standard process data
peristence into jBPM tables
newRecord = somehowGetTheUpdatedValuesOfTheNewRecord(); //as it could have been updated
inside the process rules
storeIntoDatabase(newRecord);
I would just have to make sure, that the step transitions will be triggered only via the
web service bean and not through the UI of jBPM or some other way ....
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/778800#778800]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]