[rules-users] how to update object modified by call to remote web service

lhorton LHorton at ABCLegal.com
Wed Jul 27 17:27:01 EDT 2011


We are at 5.2.0 Final

We recently moved our rules server (written in-house) to its own Tomcat
instance.  Some of our existing rules call a service to modify facts.  With
the move of the rules server, these calls to the service no longer happen in
the working memory of the rules server.  The rule must now capture the
return from the call to the remote service, in order to see the changes made
by the remote service call.

Within the rule, this change is working fine.  The RHS was:

      applicationService.applyInstruction($step);

as above, the $step fact would not be updated within the rule WM now that
the service is called remotely.  However, when I changed this to

      $step = applicationService.applyInstruction($step);

then $step did have the changes(I am verifying this by writing debug info to
the log).  BUT, the object that was passed in to execute() on the knowledge
session did NOT have the changes.  I have tried several things to fix this. 
one was to update($step) but this failed with "Update error: handle not
found for object," I assume because the fact handle changed in the object
returned from the service call.

I also tried some variations on retracting and inserting the step:

	retract($step);
	$step = applicationService.applyInstruction($step);
	insert($step);

and also tried using a different variable name:

	retract($step);
	$step2 = applicationService.applyInstruction($step);
	insert($step2);
        update($step2);

both these above did not get errors, but also did not cause the updated
object to return from session.execute() call.

To summarize:
in a call to execute() on a stateless knowledge session, an object is passed
in 
a rule fires that calls a remote service that modifies the object
within the rule, we catch the changed object that is returned from the
service call
within the rule, the changes to the object ARE visible
on the return from execute(), the changes are NOT visible

thanks for your help...


--
View this message in context: http://drools.46999.n3.nabble.com/how-to-update-object-modified-by-call-to-remote-web-service-tp3204887p3204887.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list