簡體   English   中英

WSO2 Streaming Integrator - Siddhi.io 將多個事件聚合為一個事件

[英]WSO2 Streaming Integrator - Siddhi.io Aggregate multiple events into one event

我需要將多個事件收集到一個事件中並將其視為一個事件。 輸出流應包括輸入事件作為列表。

基本上,當通過以下事件時

{InvoiceNumber:1, LineItem: 1, Value: 100}
{InvoiceNumber:1, LineItem: 2, Value: 200}
{InvoiceNumber:1, LineItem: 3, Value: 300}

我需要輸出如下所示

[InvoiceNumber:1, lineItems: [{LineItem: 1, Value: 100}, {LineItem: 2, Value: 200}, {LineItem: 3, Value: 300}]

我如何使用 WSO2 Streaming Integrator 實現這一目標? 或Siddhi.io。

我嘗試了以下操作,但它仍然將每個流插入到輸出流中

partition with (InvoiceNo of CSVInputStream)
begin

    from every e1=CSVInputStream
        within 1 min
    select e1.InvoiceNo, list:collect(e1.LineItem) as lineItems
    group by e1.InvoiceNo
    insert into AggregatedStream;
end;

不要使用分區,因為這是一個簡單的用例,請嘗試使用 windows。 您的情況下的時間批處理窗口, https://siddhi.io/en/v5.1/docs/api/latest/#timebatch-window

from CSVInputStream#window.timeBatch(1 min)
select e1.InvoiceNo, list:collect(e1.LineItem) as lineItems
group by e1.InvoiceNo
insert into AggregatedStream;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM