<div><br></div> Try:<div><br></div><div>// this is type of control fact</div><div>declare MsgSent</div><div> msg : StatusMessage </div><div>end</div><div><br></div><div>rule publish</div><div>when</div><div> $msg : StatusMessage( )</div>
<div> not MsgSent( msg == $msg )</div><div>then</div><div> // publish</div><div> insert( new MsgSent( $msg ) ); // using 5.1.1, otherwise needs to use empty constructor and set the field</div><div>end</div><div><br>
</div><div>rule cleanup</div><div>when</div><div> $snt : MsgSent( )</div><div> not StatusMessage( this == $snt.msg )</div><div>then</div><div> retract( $snt );</div><div>end</div><div><br></div><div> Edson<br><br>
<div class="gmail_quote">2010/8/29 Tina Vießmann <span dir="ltr"><<a href="mailto:tviessmann@stud.hs-bremen.de">tviessmann@stud.hs-bremen.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#ffffff" text="#000000">
Thank you, Wolfgang! :)<br>
<br>
Let's say:<br>
I'm generating StatusMessage objects during the rule processing.
They will be published. But they are also need for further
processing (so they can not be deleted after publishing).<br>
The StatusMessage objects defined as simple POJOs.<br>
<br>
If I'm publishing the StatusMessage objects using a rule like<br>
rule 'publish StatusMessages'<br>
when<br>
$msg : StatusMessage( )<br>
then<br>
// publish<br>
end<br>
In this case every StatusMessage would be send again and again. <br>
My first impression for a solution would be to define a Boolean
field 'send' that signals if the object has been send. But the field
would just be needed for Drools internal processing. So I thought of
defining this additional field using the declare statement. But if I
remember correctly from previous tries, such a things are not
possible because the declare statement with the additional field is
the definition of a new type... Am I right so far?<br>
<br>
Do you have a idea how I can solve my problem of sending an
fact/event just once but keep it in the memory for further
processing?<br>
<br>
Thank sou!<br><font color="#888888">
Tina</font><div><div></div><div class="h5"><br>
<br>
<br>
<blockquote type="cite">The usual method:<br>
You establish a TopicPublisher as a global declared in your .drl
file.<br>
global TopicPublisher topicPublisher<br>
You must set this from Java code using<br>
TopicPublisher topicPublisher = ...;<br>
statefulKnowledgeSession.setGlobal( "publisher", topicPublisher
)<br>
and then you use it in any RHS code.<br>
<br>
Of course, a TopicPublisher could also be (field of) some fact,<br>
but this shouldn't be necessary for such a central service.<br>
<br>
-W<br>
<br>
<br>
<div class="gmail_quote">On 29 August 2010 19:16, Tina Vießmann <span dir="ltr"><<a href="mailto:tviessmann@stud.hs-bremen.de" target="_blank">tviessmann@stud.hs-bremen.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"> Hi,<br>
<br>
I've got a simple question.<br>
<br>
How can I get generated facts out of the memory (for
publishing them<br>
using JMS)?<br>
<br>
Thanks :)<br>
Tina<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
</div>
<br>
<pre><fieldset></fieldset>
_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
<br>
</div></div></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>