WSO2 CEP代理程序(KPI Analyzer)示例不适用于aggragate查询

时间:2013-04-17 08:53:44

标签: wso2 complex-event-processing broker

我正在研究Apache WSO2 CEP,我正在尝试做一些符合我要求的场景。

首先,我执行此链接中KPI Analyzer中解释的示例,然后我就可以正确查看结果。在那之后,我想从这个

中稍微改变那个样本中的桶
from phoneRetailStream[totalPrice>2500 and quantity>3]
insert into highPurchaseStream
buyer, brand, quantity, totalPrice; 

到这个

from phoneRetailStream#window.length(5)
insert into highPurchaseStream
sum(quantity) as quantitySum, sum(totalPrice) as totalpriceSum
group by  brand;

并相应地更改了元组映射。但是这种配置总是给我错误

 [java] Wrongly formatted event sent for carbon.super
 [java] org.wso2.carbon.databridge.core.exception.EventConversionException: Error when converting org.wso2.high.purchase.buyers.new:1.6.0 of event bundle with events 4
 [java]     at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.createEventList(ThriftEventConverter.java:126)
 [java]     at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.toEventList(ThriftEventConverter.java:88)
 [java]     at org.wso2.carbon.databridge.core.internal.queue.QueueWorker.run(QueueWorker.java:72)
 [java]     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
 [java]     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
 [java]     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
 [java]     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 [java]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 [java]     at java.lang.Thread.run(Thread.java:662)
 [java] Caused by: java.lang.NullPointerException
 [java]     at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.toObjectArray(ThriftEventConverter.java:49)
 [java]     at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.createEventList(ThriftEventConverter.java:116)
 [java]     ... 8 more

我不能在jmsbroker以外的这些样本中使用siddhi语言的聚合函数(sum,avg等)。这种情况可能有什么问题?

@Mohanadarshan

这是我的bucket xml文件的最后一个版本

<bucket name="KPIAnalyzer" xmlns="http://wso2.org/carbon/cep">
    <description>
Notifies when a user purchases more then 3 phones for the total price higher than $2500.
    </description>
    <engineProviderConfiguration engineProvider="SiddhiCEPRuntime">
        <property name="siddhi.persistence.snapshot.time.interval.minutes">0</property>
        <property name="siddhi.enable.distributed.processing">false</property>
    </engineProviderConfiguration>
    <input topic="org.wso2.phone.retail.store/1.2.0" brokerName="localAgentBroker">
        <tupleMapping stream="phoneRetailStream" queryEventType="Tuple">
            <property name="brand" inputName="brand" inputDataType="payloadData"
                      type="java.lang.String"/>
            <property name="quantity" inputName="quantity" inputDataType="payloadData"
                      type="java.lang.Integer"/>
            <property name="totalPrice" inputName="total" inputDataType="payloadData"
                      type="java.lang.Integer"/>
            <property name="buyer" inputName="buyer" inputDataType="payloadData"
                      type="java.lang.String"/>
        </tupleMapping>
    </input>
    <query name="KPIQuery">
        <expression>
from phoneRetailStream#window.length(5)
insert into highPurchaseStream
sum(quantity) as quantitySum, sum(totalPrice) as totalpriceSum
group by  brand;
        </expression>
        <output topic="org.wso2.high.purchase.buyers.new/1.6.0" brokerName="externalAgentBroker">
            <tupleMapping>
                <metaData>
                </metaData>
                <correlationData/>
                <payloadData>
                    <property name="quantity" valueOf="quantitySum" type="java.lang.Integer"/>
                    <property name="purchasePrice" valueOf="totalpriceSum" type="java.lang.Integer"/>
                </payloadData>
            </tupleMapping>
        </output>
    </query>
</bucket>

谢谢你的帮助。

1 个答案:

答案 0 :(得分:2)

我检查了你的siddhi查询,它与siddhi引擎一起正常工作,查询没有任何问题......

我已经检查过KPI分析器示例,它对您的查询也没有任何问题...请确保您是否对输出元组映射进行了适当的配置..

我需要提一下,“存储桶可编辑用户界面”存在一些问题。请验证/ repository / deployment / server / cepbuckets /中的bucket xml文件是否正确...(有时删除属性时,不会正确删除)

更改

<property name="quantity" valueOf="quantitySum" type="java.lang.Long"/>
<property name="purchasePrice" valueOf="totalpriceSum" type="java.lang.Long"/>

谢谢,

莫汉