Hi all,

In tutorial[1] which we are using for our labkit as well has the siddhi app
as follows.

@App:name('MaterialThresholdAlertApp')

@source(type = 'http', @map(type = 'json'))
define stream MaterialConsumptionStream(name string, user string,
amount double);

@source(type = 'http', @map(type = 'json'))
define stream MaterialSupplyStream(name string, supplier string, amount double);

@sink(type='log', prefix='Materials that go beyond sustainability threshold:')
define stream MaterialThresholdAlertStream(name string, supplyAmount
double, consumptionAmount double, user string, supplier string);

from MaterialConsumptionStream#window.time(1 hour) as c
        join MaterialSupplyStream#window.time(1 hour) as s
        on c.name == s.name
select s.name, s.amount as supplyAmount, c.amount as
consumptionAmount, user, supplier
group by s.name
having s.amount * 0.95 < c.amount
insert into MaterialThresholdAlertStream;


But in-order to check the total consumed amount is greater than 95% of
supplied amount, we should have the query as follows.

select s.name, sum(s.amount) as supplyAmount, sum(c.amount) as
consumptionAmount, user, supplier


But the results gets printed as follows when we simulate using the
following steps,

   1. Simulate "*MaterialSupplyStream*" with "sugar, yyy, 100"
   2. Simulate "*MaterialConsumptionStream*" with "sugar, xxx, 97"
      1. Materials that go beyond sustainability threshold: :
      Event{timestamp=1539794935863, data=[sugar, *100.0*, 97.0, yyy, xxx],
      isExpired=false}
      3. Simulate "*MaterialConsumptionStream*" with "sugar, xxx, 97"
      1. Materials that go beyond sustainability threshold: :
      Event{timestamp=1539794936733, data=[sugar, *200.0*, 194.0, yyy,
      xxx], isExpired=false}
      4. Simulate "*MaterialConsumptionStream*" with "sugar, xxx, 97"
      1. Materials that go beyond sustainability threshold: :
      Event{timestamp=1539794937643, data=[sugar, *300.0*, 291.0, yyy,
      xxx], isExpired=false}

Even though we dont send event to the *MaterialSupplyStream,* the summation
adds 100 each at each join. It should be resulted with the initial 100 that
we sent. Is it? Please correct me if I'm wrong.

Best Regards,
Ramindu.

1. https://docs.wso2.com/display/SP430/Correlating+Simple+Events


-- 
*Ramindu De Silva*
Senior Software Engineer
WSO2 Inc.: http://wso2.com
lean.enterprise.middleware

email: ramin...@wso2.com <sanj...@wso2.com>
mob: +94 719678895
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to