我有一系列事件,我们称之为Foo
,它们按时间顺序插入,我还有另一个事件流Bar
,它们也按时间顺序插入。
我有一条规则,它将Bar
s与Foo
s进行模糊匹配,我想要做的是用最早的{{Bar
来加工Foo
1}},有没有办法确保按事件的时间顺序触发规则 - 有点像salience
但是时间......
Foo
以比Bar
更快的速度到达,而不是每个Foo
都会有Bar
。
答案 0 :(得分:1)
我不确定您要实现的目标,但如果您希望将最早的Foo
与最早的Bar
匹配,则可以尝试以下内容:
rule "Oldest Far with oldest Bar"
when
$oldestF: Foo()
not Foo( this before $oldestF )
$oldestB: Bar(//in here you can correlate this Bar with the $oldestF)
not Bar( this before $oldestBar)
then
//do something
end
如果你想按顺序处理这些匹配,那么你可能想在事实中使用一个标志,这样一旦处理完循环就可以丢弃它们:
rule "Oldest Far with oldest Bar"
when
$oldestF: Foo( processed == false )
not Foo( this before $oldestF )
$oldestB: Bar( processed == false //in here you can correlate this Bar with the $oldestF)
not Bar( this before $oldestBar)
then
//do something
modify($oldestF){ setProcessed(true) };
modify($oldestB){ setProcessed(true) };
end
希望它有所帮助,