[rules-users] Best pattern for getting results OUT of Integration server?

dunnlow dunnlow at yahoo.com
Mon Jan 6 19:05:51 EST 2014


I have some confusion about running rules in the Integration Server (v5.5).

I am sending POJOs to the server from a camel (v2.10) Spring client app. 
The client inserts a POJO (via batchexecutioncommand) and the rules change
an attribute on the POJO to return the value to the client.

I know, I know, changing attributes of facts is frowned upon (but when I
started I didn't know any better... I swear).

The problem I'm having (surprise) is that updating the fact (to return to
the client app) is causing unwanted activations, no-loops, lock-on-actives
etc etc.   So, I'm looking into changing this and inserting two string
objects into my command so that the rules only modify those string objects.

My questions:
1) Is that the best (/a good) way to implement this?

2) My big question/misunderstanding:  Does the integration server handle the
batchexecutioncommands in series or is it inserting into the working memory
in parallel (ie. are all executions from the first insert completed before
the next batchexecutioninsert command is evaluated)?

For example,

If I have a loop that inserts one POJO (Fact.class) and two POJOs (S.class,
a simple class with one string class variable)  can I safely do something
like below (is the engine able to keep Fact1 with its inserted S1 and S2
objects separate from the next S objects that might be inserted immediately
after OR might all Facts and S objects get confused (due to multi-threading,
parallel operation, etc):

      rule "evaluate a Fact POJO"
      when
          $fact1 : Fact (value > 100, card=="NONE")
          $s1 : S ()
          $s2 : S (this != $s1)
      then
           $s1 = "OK"
           $s2 = "BLUECARD"
      end

      rule "remove inserted objects so memory doesn't fill up"
          salience -1000
      when
          $completedFact : Fact ()
      then
          retract ($completedFact)
      end

      rule "remove inserted objects so memory doesn't fill up"
          salience -1000
      when
          $completedS : S ()
      then
           retract($completedS)
      end

My client will use the resulting s1 and s2 values so I obviously don't want
the returned s1 and s2 values for fact1 to be confused with the s1 and s2
values for fact2.

3) Currently, I need to retract the pojos I insert once the processing is
done(like above) -- kinda ugly.  Is there a way to implement a "logical"
insert for the integration server or a better way to handle this?

Thanks for any thoughts!
-J



--
View this message in context: http://drools.46999.n3.nabble.com/Best-pattern-for-getting-results-OUT-of-Integration-server-tp4027546.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list