【发布时间】:2016-02-07 15:13:01
【问题描述】:
我想用场景测试drools 6.3,但是在特殊情况下我遇到了问题。 这是我的一个简单形式的场景: 我在生成事件的模拟网络中有两个系统,A 和 B。我想写两条规则来找出这些事件中的模式。测试此场景的两条规则是:
declare A
@timestamp(timestampA)
end
declare B
@timestamp(timestampB)
end
Rule “1”
When
accumulate( A() over window:time( 10s ) ; s:count(1) ; s>1)
Then
System.out.println( " Rule 1 matched " );
Rule “2”
When
B()
Then
System.out.println( " Rule 2 matched " );
每个事件的时间戳是每个系统中生成的日志的时间戳,当它被 drools 接收并插入工作内存时。 我正在使用带有伪时钟的 STREAM 模式,因为来自系统 B 的事件由于网络拥塞而延迟 25 分钟接收,我应该手动调整会话时钟。会话时钟设置为插入到会话中的每个事件的时间戳。并且在插入每个事件时都会触发所有规则。 当接收和插入事件的顺序如下正确匹配时。
Event A received at 10:31:21 – Session clock : 10:31:21 – insert A and fire
Event A received at 10:31:23 - Session clock : 10:31:23 – insert A and fire
Rule 1 matched
Event B received at 10:06:41 - Session clock : 10:06:41 – insert B and fire
Rule 2 matched
但是当接收和插入事件的顺序如下所示时匹配不正确:
Event A received at 10:31:21 – Session clock : 10:31:21 – insert A and fire
Event B received at 10:06:41 - Session clock : 10:06:41 – insert B and fire
Rule 2 matched
Event A received at 10:31:23 - Session clock : 10:31:23 – insert A and fire
当第二个 A 事件插入时,最后 10 秒的两个 A 事件在工作内存中,但规则 1 不匹配。为什么?
【问题讨论】:
标签: drools