For jBPM 5, How to access a fact in the working memory from WorkItemHandler
Environment
- Red Hat JBoss BRMS
- 5.3
Issue
- How to access a fact in the working memory from WorkItemHandler
- How to re-matching rules with a specific fact object from WorkItemHandler
- How to access a ksession from WorkItemHandler
Resolution
-
How to access a fact in the working memory from WorkItemHandler
To modify the facts which is inserted into the working memory byksession.insert()
, you can use the following API.
ksession.getObject(FactHandle);
ksession.getObjects();
ksession.getObjects(ObjectFilter); -
How to re-matching rules with a specific fact object from WorkItemHandler
If you modify the fact object in the working memory and want to re-matching with rules again, please use a following API.
ksession.update(FactHandle, Object);
By invokingksession.update()
, agenda will be generated. So please callksession.fireAllRule()
if you need it. By using the following API, you can get an object for the first parameter, FactHandle, to callksession.upate()
.
ksession.getFactHandle(Object);
ksession.getFactHandles();
ksession.getFactHandles(ObjectFilter);
Alsoksession.insert()
returns FactHandle object, then you can maintain the returned object in your application. -
How to access a ksession from WorkItemHandler
You need to provide a way to access ksession from WorkItemHandler. You may create a local variable in WorkItemHandler to keep a ksession object. In general, you can pass and store ksession object during execution for a WorkItemHandler's constructor.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments