siddhi icon indicating copy to clipboard operation
siddhi copied to clipboard

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

Open salvalcantara opened this issue 5 years ago • 3 comments

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).

salvalcantara avatar Jan 15 '20 20:01 salvalcantara

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.

xtrmstep avatar Jan 20 '20 07:01 xtrmstep

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

salvalcantara avatar Jan 20 '20 12:01 salvalcantara

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.

pcnfernando avatar Jan 23 '20 17:01 pcnfernando