JBoss Drools 插入来自 DRL 的事实

发布于 2024-10-17 18:01:05 字数 245 浏览 5 评论 0原文

我需要我的工作内存了解 DRL 中创建的事实,如下所示:

rule "Your First Rule"
when
    $testRule : TestRule(count >= 100)
then 
    System.out.println("100 PACKETS");
end

有没有办法让工作内存了解 TestRule 事实,然后能够更新?我的目标是让规则知道何时收到 100 个数据包。

I need my WorkingMemory to be aware of facts which are created in the DRL as follows:

rule "Your First Rule"
when
    $testRule : TestRule(count >= 100)
then 
    System.out.println("100 PACKETS");
end

Is there a way of getting the WorkingMemory to become aware of the TestRule fact and then be able to be updated? My objective is to get the rule to know when 100 packets have been received.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若能看破又如何 2024-10-24 18:01:05

通常我会创建一些东西作为规则的一部分并将其用作标志。如果你不需要创建任何东西,那么你可以创建一个标志,例如

rule "Your First Rule"
when
    $testRule : TestRule(count >= 100)
    not         Flag(id="packets")
then 
    System.out.println("100 PACKETS");
    insert( new Flag("packets") )
    update( $testRule )
end

我不认为这段代码是正确的,但我认为你可以明白这个想法......并且你需要创建一个名为旗帜。需要更新来告诉 drools 必须更新 rete 树。

usually I create something as part of a rule and use it as a flag. If you don't need to create anything, then you can create a flag, for example

rule "Your First Rule"
when
    $testRule : TestRule(count >= 100)
    not         Flag(id="packets")
then 
    System.out.println("100 PACKETS");
    insert( new Flag("packets") )
    update( $testRule )
end

I don't think this code is correct, but I think you can get the idea... And you'll need to create a class called Flag. The update is needed to tell drools that is has to update the rete tree.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文