Ragavan,

I think we will need a custom extension here. Let me explain.
Siddhi can easily separate out events based on slot count. But here for
condition 2, we need to check count plus whether slots are subsequent.
These is no single expression which does that hence we need to look at a
multiple query scenario.

Multi query approach faces following issue. When you batch window and get a
count, only your last event will be propagated further with final count.
Which means after counting query you
 will loose all the slot details making it impossible to evaluate decision
2.

So the proposed solution is to write a custom stream processor
extension[1].  Extension will collect events for a period of one minute and
then identify the condition which will match collected events. Then based
on that insert an additional field to stream stating condition. Then you
can write a second query to filter using that field and send to different
endpoints.

I am adding few of my team mates to the thread. They will respond if they
can think of a better solution

[1]
https://docs.wso2.com/display/CEP400/Writing+a+Custom+Stream+Processor+Extension

Thanks
Tishan

On Wed, Feb 17, 2016 at 5:03 PM, Ragavan Thiru <[email protected]> wrote:

> yes exactly.
>
> On Wed, Feb 17, 2016 at 4:58 PM, Tishan Dahanayakage <[email protected]>
> wrote:
>
>> Hi,
>>
>> So the requirement is for one minute time per fbid
>>
>> 1. One slot received -> endpoint1
>> 2. 2-4 subsequent slots received -> endpoint2
>> 3. Everything else -> endpoint3
>>
>> Are we on the same page?
>>
>> Thanks
>> Tishan
>>
>> On Wed, Feb 17, 2016 at 4:54 PM, Ragavan Thiru <[email protected]> wrote:
>>
>>> Yes all other than satisfy requirement 1 with one exception.
>>>
>>> Exception is if only one event is there, we need to trigger different
>>> endpoint.
>>>
>>> For example, slot 3 or 5 or 7
>>>
>>> On Wed, Feb 17, 2016 at 4:48 PM, Tishan Dahanayakage <[email protected]>
>>> wrote:
>>>
>>>> Hi Ragavan,
>>>>
>>>> Have few questions regarding your requireemnt.
>>>>
>>>>
>>>> On Wed, Feb 17, 2016 at 3:05 PM, Ragavan Thiru <[email protected]>
>>>> wrote:
>>>>
>>>>>
>>>>>
>>>>> What we have to find is, for a given ( fbid) if 2 or 3 or 4 *subsequent
>>>>> *slot comes within a minute we need to trigger an endpoint.
>>>>> ​
>>>>>
>>>>>
>>>>
>>>>> For example, given,
>>>>>
>>>>> "deviceId": "123", "fbid":"123890123890",
>>>>>
>>>>> 1. If slots 5, 6,7,4
>>>>>
>>>>> OR  slots 13,14
>>>>>
>>>>> OR slots 2,4,3 comes I need to trigger an endpoint.
>>>>>
>>>>> AND so on.
>>>>>
>>>>> ​Understood this part. Basically if 2-4 subsequent slots come within
>>>> one minute (even in out of order)​
>>>>
>>>> ​you need to trigger an endpoint. ​
>>>>
>>>>> 2. If 1,3 or 1,2,3,4,5 or 5,8,9 comes or more than 4 slots comes we need 
>>>>> to trigger different endpoint and so on
>>>>>
>>>>> ​Is this like everything else other than which does not satisfy
>>>> requirement 1 or something else?​
>>>>
>>>>
>>>>> I started like this,
>>>>>
>>>>> define stream event1Stream (topic string, fbId string,timestamp 
>>>>> string,slot int, deviceId string,deviceType string,eventType 
>>>>> string,format string,_msgid string);
>>>>>
>>>>> partition with ( fbId of event1Stream )
>>>>>
>>>>> begin
>>>>>
>>>>>      from event1Stream#window.timeBatch(1 min)
>>>>>     select fbId, deviceId, slot, count(slot) as slotCount
>>>>>     insert into #DeviceTempStream;
>>>>>
>>>>>
>>>>>    from #DeviceTempStream[slotCount > 4]
>>>>>    select fbId, deviceId, slot
>>>>>    insert into deviceTempStream;
>>>>> end;
>>>>>
>>>>> Can you please help me to achieve the above scenario?
>>>>>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> T.Ragavan.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Tishan Dahanayakage
>>>> Software Engineer
>>>> WSO2, Inc.
>>>> Mobile:+94 716481328
>>>>
>>>> Disclaimer: This communication may contain privileged or other
>>>> confidential information and is intended exclusively for the addressee/s.
>>>> If you are not the intended recipient/s, or believe that you may have
>>>> received this communication in error, please reply to the sender indicating
>>>> that fact and delete the copy you received and in addition, you should not
>>>> print, copy, re-transmit, disseminate, or otherwise use the information
>>>> contained in this communication. Internet communications cannot be
>>>> guaranteed to be timely, secure, error or virus-free. The sender does not
>>>> accept liability for any errors or omissions.
>>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>> T.Ragavan.
>>>
>>
>>
>>
>> --
>> Tishan Dahanayakage
>> Software Engineer
>> WSO2, Inc.
>> Mobile:+94 716481328
>>
>> Disclaimer: This communication may contain privileged or other
>> confidential information and is intended exclusively for the addressee/s.
>> If you are not the intended recipient/s, or believe that you may have
>> received this communication in error, please reply to the sender indicating
>> that fact and delete the copy you received and in addition, you should not
>> print, copy, re-transmit, disseminate, or otherwise use the information
>> contained in this communication. Internet communications cannot be
>> guaranteed to be timely, secure, error or virus-free. The sender does not
>> accept liability for any errors or omissions.
>>
>
>
>
> --
> Regards,
> T.Ragavan.
>



-- 
Tishan Dahanayakage
Software Engineer
WSO2, Inc.
Mobile:+94 716481328

Disclaimer: This communication may contain privileged or other confidential
information and is intended exclusively for the addressee/s. If you are not
the intended recipient/s, or believe that you may have received this
communication in error, please reply to the sender indicating that fact and
delete the copy you received and in addition, you should not print, copy,
re-transmit, disseminate, or otherwise use the information contained in
this communication. Internet communications cannot be guaranteed to be
timely, secure, error or virus-free. The sender does not accept liability
for any errors or omissions.
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to