[
https://jira.jboss.org/browse/JBRULES-2608?page=com.atlassian.jira.plugin...
]
Anatoly Polinsky commented on JBRULES-2608:
-------------------------------------------
Mauricio,
Thanks for the response.
I believe there is a slight misunderstanding. Let me try this in a simpler form:
GIVEN: "An ArrayList<String> which is a process wide variable"
GIVEN: "Three WorkItems"
GIVEN: "All workitems need to access this list"
GIVEN: "First workitem calls external system and changes/populates this
list"
GIVEN: "First workitem completes by providing this list as a result
parameter"
GIVEN: "Second workitem picks this list up (no problem here), does something
else, and goes to sleep" [ the changed list is PERSISTED ]
GIVEN: "Second workitem is completed externally [ loadStatefulKnowledgeSession
=> session.getWorkItemManager().completeWorkItem(.. .. ..) ]"
PROBLEM: "Third workitem needs to pick up the same
list that was PERSISTED and is not able to do so"
LOOKING FOR SOLUTION: "To access the (previously persisted) list by the third
workitem"
Thank you,
/Anatoly
P.S. Again: "Persistence in computer science refers to the characteristic of state
that OUTLIVES the process that created it". The whole point of persisting the
variable is that you can RESTORE it later on.
At the moment of completing the workitem we rely on the fact that Drools understands what
persistence is, and, at that moment of completing the workitem externally, we _do not
have_ the list, because, it is PERSISTED in the data store, and we expect Drools to
RESTORE it.
Variable Persistence Overwrites NULL Values over Persisted Values
-----------------------------------------------------------------
Key: JBRULES-2608
URL:
https://jira.jboss.org/browse/JBRULES-2608
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: All
Affects Versions: 5.1.0.FINAL
Environment: N/A
Reporter: Anatoly Polinsky
Assignee: Mauricio Salatino
Attachments: difference-between-first-and-second-work-item.png,
drools-vp-jira.zip, passing-list-process-test.png, passing-list-process.png
Original Estimate: 4 hours
Remaining Estimate: 4 hours
Drools Flow
=========
For non-String variables (Serializ..ble, Entities, etc..), Drools overwrites NULLs
when a (JPA) process is resumed ( a workitem is completed ).
1. Here is a use case: a List ( ArrayList ) is passed to the process in start as a
parameter
2. First work item sees ( maps in ) the List, and can work with it inside the work
item handler
3. First work item does not complete: process goes to sleep.
4. When the session is reloaded, the first work item is completed
5. All the persisted variables ( including the "list" ) are restored
6. Second work item is taking in the list ( it maps in )
7. However at this point it is NULL
It seems that when the context is closed, after resolving variables, the following
(WorkItemNodeInstance):
VariableScopeInstance variableScopeInstance = ( VariableScopeInstance )
resolveContextInstance( VariableScope.VARIABLE_SCOPE,
mapping.getValue() );
does no longer have the restored variables, and rather NULLs, since internally
variables are compared with a "result map" that was passed to the previous work
item.
This means that persisted variables are restored internally, but then overwritten
internally by NULLs.
/Anatoly
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira