WSO2 Siddhi复杂事件处理器问题

时间:2018-11-12 19:03:05

标签: wso2 siddhi wso2sp

环境:WSO2流处理器4.3.0

假设我有两个非常简单的流:

正在实时(t1)交付新创建的请求(未满足)的流

RequestStream(requestId)

实时(t2)满足请求后,requestIds出现的流

FulfilmentStream(requestId)

保证t2总是> t1

如何实现SiddhiQL语句以标识出现在 RequestStream(event1)上但未出现在 FulfilmentStream(event2)中的requestIds是因为event1?

基于Tishan的工作Siddhi App答案:

@App:name('FailedToFulfillInAmountOfTime')

@source(
type="kafka",
topic.list="some_topic",
threading.option="single.thread",
group.id="some_group",
bootstrap.servers="xxx.xxx.xxx.xxx:6667",
@Map(type="json", @attributes(request_id = '$.alarm_id', severity = '$.severity', managed_object = '$.ManagedObject')))
define stream OrigAlarmStream (request_id int, severity string, managed_object string); 

@sink(type='log', prefix='Got this execution request')
define stream RequestStream (request_id int, severity string, managed_object string);

@sink(type='log', prefix='Got this fulfillment confirmation:')
define stream FulfillmentStream (request_id int, severity string, managed_object string);

@sink(type='log', prefix='This fulfillment was not done within 1 min:')
define stream AlertStream(request_id int);

@info(name='getExpiredRequests')
from every e1=RequestStream -> not FulfillmentStream[e1.request_id == request_id] for 1 min
select e1.request_id
insert into AlertStream;

@info(name='CopyFulfillments')
from OrigAlarmStream[severity == 'Clear']
select request_id, severity, managed_object
insert into FulfillmentStream;

@info(name='CopyRequests')
from OrigAlarmStream[severity != 'Clear']
select request_id, severity, managed_object
insert into RequestStream;

1 个答案:

答案 0 :(得分:1)

您可以使用逻辑模式来满足您的要求。请参考下面的查询。

from e1=RequestStream -> not e2=FulfilmentStream[e1.requestId == e2.requestId] for '5 min'
select e1.requestId as requestId
insert into AlertStream;

在这里,我们定义了一个没有条件的模式。当RequestStream中的事件到来且在5分钟内没有事件进入FulfilmentStream时,将触发此事件。有关更多信息,请参考logical patterns