2014-02-07 74 views
0

我與wso2cep3.0.0工作, 我的輸入源和出把源JMs.I我寫事件的輸入適配器和輸出事件適配器這樣事件流是如何工作的wso2cep3.0.0

輸入適配器

<?xml version="1.0" encoding="UTF-8"?> 
<inputEventAdaptor name="jmsProxy" statistics="disable" trace="enable" 
    type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager"> 
    <property name="java.naming.provider.url">tcp://localhost:61616</property> 
    <property name="transport.jms.SubscriptionDurable">false</property> 
    <property name="transport.jms.UserName">admin</property> 
    <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property> 
    <property name="transport.jms.Password">admin</property> 
    <property name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</property> 
    <property name="transport.jms.DestinationType">queue</property> 
</inputEventAdaptor> 

和我

輸出事件適配器

<?xml version="1.0" encoding="UTF-8"?> 
<outputEventAdaptor name="OUTJmsProxy" statistics="disable" trace="disable" 
    type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager"> 
    <property name="java.naming.security.principal">admin</property> 
    <property name="java.naming.provider.url">tcp://localhost:61616</property> 
    <property name="java.naming.security.credentials">admin</property> 
    <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property> 
    <property name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</property> 
    <property name="transport.jms.DestinationType">queue</property> 
</outputEventAdaptor> 

和jmsproxy JMS隊列我輸入的消息是這樣的

<soapenv:Body xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> 
    <uuid>cc253480-95b3-418e-b282-7e87f885c99e</uuid> 
    <Remarks>t4</Remarks> 
    <ReadingsLiteTaildtos> 
     <ReadingsLiteTaildto> 
     <FinalValue>70</FinalValue> 
     <InputText>Chiller Feeder Current R - Ph</InputText> 
     <InputValue>0.0</InputValue> 
     <ParameterId>-2499999974</ParameterId> 
     <SlNo>1</SlNo> 
     </ReadingsLiteTaildto> 
     <ReadingsLiteTaildto> 
     <FinalValue>70</FinalValue> 
     <InputText>Chiller Feeder Current Y - Ph</InputText> 
     <InputValue>0.0</InputValue> 
     <ParameterId>-2499999973</ParameterId> 
     <SlNo>2</SlNo> 
     </ReadingsLiteTaildto> 
     <ReadingsLiteTaildto> 
     <FinalValue>70</FinalValue> 
     <InputText>Chiller Feeder Current B - Ph</InputText> 
     <InputValue>0.0</InputValue> 
     <ParameterId>-2499999972</ParameterId> 
     <SlNo>3</SlNo> 
     </ReadingsLiteTaildto> 
     <ReadingsLiteTaildto> 
     <FinalValue>70</FinalValue> 
     <InputText>Chiller Energy Meter Reading</InputText> 
     <InputValue>0.0</InputValue> 
     <ParameterId>-2499999971</ParameterId> 
     <SlNo>4</SlNo> 
     </ReadingsLiteTaildto> 
    </ReadingsLiteTaildtos> 
    <ReadingDateTime>1381757157596</ReadingDateTime> 
    <PartyBranchId>-2500000000</PartyBranchId> 
    <ParametersetId>-2499999974</ParametersetId> 
    <AssetId>-2499999995</AssetId> 
    <TaskId>811291126760647</TaskId> 
    <WorkOUId>-1</WorkOUId> 
    <activityid>-2500000000</activityid> 
    <userid>-2499999993</userid> 
    <entrymode>0</entrymode> 
    <DeviceId>-1</DeviceId> 
</soapenv:Body> 

我希望當最終值越過最大引發一個事件價值像超過100 所以我會如何寫流和

ExecutionPlan

在流管理器-config.xml文件由 3部分

1.metaData 2.Correlation數據3.Payload數據

所以上述消息我將如何定義哪些數據在哪個部分 我們應該定義輸入負載和輸出負載以及相同的流配置文件,否則我們需要定義separ吃

就是這個用例CEP幫助或不

提前

感謝名單。

回答

1

是的,這是CEP的典型用例。

您可以使用類似於以下的'事件生成器'。

<?xml version="1.0" encoding="UTF-8"?> 
<eventBuilder name="ReadingsDtoBuilder" statistics="disable" 
    trace="disable" xmlns="http://wso2.org/carbon/eventbuilder"> 
<from eventAdaptorName="jmsEventReceiver" eventAdaptorType="jms"> 
    <property name="transport.jms.Destination">ReadingsQueue</property> 
</from> 
<mapping customMapping="disable" 
    parentXpath="//ReadingsLiteTaildtos" type="xml"> 
    <property> 
     <from xpath="//ReadingsLiteTaildto/ParameterId"/> 
     <to name="meta_parameterId" type="string"/> 
    </property> 
    <property> 
     <from xpath="//ReadingsLiteTaildto/Slno"/> 
     <to name="meta_slno" type="string"/> 
    </property> 
    <property> 
     <from xpath="//ReadingsLiteTaildto/FinalValue"/> 
     <to name="finalValue" type="int"/> 
    </property> 
    <property> 
     <from xpath="//ReadingsLiteTaildto/InputText"/> 
     <to name="inputText" type="string"/> 
    </property> 
    <property> 
     <from xpath="//ReadingsLiteTaildto/InputValue"/> 
     <to name="inputValue" type="double"/> 
    </property> 
</mapping> 
<to streamName="org.sample.readings.dto.stream" version="1.0.0"/> 
</eventBuilder> 

執行計劃可以如下。

<?xml version="1.0" encoding="UTF-8"?> 
<executionPlan name="ReadingsAnalyzer" statistics="disable" 
    trace="disable" xmlns="http://wso2.org/carbon/eventprocessor"> 
    <description>This execution plan analyzes readings and triggers notifications based on  threshold.</description> 
    <siddhiConfiguration> 
    <property name="siddhi.enable.distributed.processing">false</property> 
    <property name="siddhi.persistence.snapshot.time.interval.minutes">0</property> 
    </siddhiConfiguration> 
    <importedStreams> 
    <stream as="readings" name="org.sample.readings.dto.stream" version="1.0.0"/> 
    </importedStreams> 
    <queryExpressions><![CDATA[from readings[finalValue > 100] 
select * 
insert into notificationStream;]]></queryExpressions> 
    <exportedStreams> 
    <stream name="notificationStream" valueOf="notificationStream" version="1.0.0"/> 
    </exportedStreams> 
</executionPlan> 

您可以定義裏面流的流經理-config.xml文件類似於以下。

<streamDefinition name="org.sample.readings.dto.stream" version="1.0.0"> 
<metaData> 
     <property name="parameterId" type="STRING"/> 
     <property name="slno" type="STRING"/> 
</metaData> 
    <payloadData> 
     <property name="finalValue" type="INT"/> 
     <property name="inputText" type="STRING"/> 
     <property name="inputValue" type="DOUBLE"/> 
    </payloadData> 
</streamDefinition> 
<streamDefinition name="notificationStream" version="1.0.0"> 
<metaData> 
     <property name="parameterId" type="STRING"/> 
     <property name="slno" type="STRING"/> 
</metaData> 
    <payloadData> 
     <property name="finalValue" type="INT"/> 
     <property name="inputText" type="STRING"/> 
     <property name="inputValue" type="DOUBLE"/> 
    </payloadData> 
</streamDefinition> 
+0

感謝名單我會嘗試..然後讓你知道我是否觸擊 –

+0

如何添加事件formater –

+0

我沒有得到任何事件與上述配置我把2消息放入jmsProxy但消息無法移入cep我認爲Inputeventbuilder錯誤 –