[rules-users] Best pattern for getting results OUT of Integration server?
Wolfgang Laun
wolfgang.laun at gmail.com
Tue Jan 7 02:13:56 EST 2014
On 07/01/2014, dunnlow <dunnlow at yahoo.com> wrote:
> 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).
Where did you get this notion, "changing...frowned upon"? It's a
natural enough operation, and the Command lets you request that the
fact object is returned to sender.
>
> 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.
Consider calling setX() without modify/update. The returned object
should show the new values, but the Engine will be "blind" to the
updates (which, apparently, is just what you want).
> 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?
No, see below.
>
> 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)?
A batch executions command is executed in a sequential way.
>
> 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"
This will most certainly NOT do what I think that you think it does,
and it will even do twice, what it does, which doesn't make it any
better.
> 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.
That's the way it is - provided the session remains active and continues.
Another technique that's recommended for returning results is by means
of a global. (I think this is discussed in the Expert manual.)
-W
> 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.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list