siddhi-io / siddhi

Stream Processing and Complex Event Processing Engine
http://siddhi.io
Apache License 2.0
1.51k stars 526 forks source link

How to run N parallel patterns and reset all of them on every detection? #1614

Open salvalcantara opened 4 years ago

salvalcantara commented 4 years ago

Description:

I would like to run several patterns in parallel and restart all them every time there is a detection. For example, let's consider the following two pattern queries:

from every A -> B -> C select "ABC" as msg into Output
from every A -> C -> B select "ACB" as msg into Output

together with the following events:

a1, b1, c1, b2

The above application would generate the output events "ABC" and "ACB" after c1 and b2, respectively. What I would like instead is to just output the "ABC" after c1 and restart the patterns after that, so that b2 does not produce the output message "ACB".

Is there a way to achieve this?

Affected Siddhi Version: This basically affects all versions, including the current one (5.1).

xtrmstep commented 4 years ago

I think it would be possible to achieve by adding intermediate stream and additional pattern. Although it's depends on the task. If the task allows, then instead of inserting events to Output stream, I would insert them into another stream. I also would add another pattern which inserts the first occurrence from the two happened into the Output. So that you'll get only one event ABC. But I admit this approach is not generic solution for the problem.

salvalcantara commented 4 years ago

@xtrmstep Thanks for your reply. Indeed I am not sure whether this can be accomplished in the general case. Any thoughts on this @mohanvive ?

pcnfernando commented 4 years ago

At the moment, Siddhi don't have a generic approach to accomplish this. As @xtrmstep mentioned we can try to figure out workarounds for the specific tasks.

Furthermore, let us consider improving Siddhi to in-cooperate this improvement in our future releases.