Hi Grainier,

Thank you for the prompt help. As per the discussion we had offline, I had
separate out above execution plan in to two plans as follows:

*Plan 1*

@Export('timer.stream:1.0.0')
define stream timeStream (user string, type string);

define trigger cronTriggerStream at '0 * * ? * *' ;

from cronTriggerStream
select "admin" as user, "android" as type
insert into timeStream;

*Plan 2*

@Import('timer.stream:1.0.0')
define stream timeStream (user string, type string);

@Export('org.wso2.iot.operation:1.0.0')
define stream operation (meta_deviceIdentifiers string, meta_deviceType
string, code string, type string, isEnabled bool, payLoad string);

from timeStream
select device:getDevicesOfUser(user, type) as meta_deviceIdentifiers, type
as meta_deviceType, "NOTIFICATION" as code, "PROFILE" as type, true as
isEnabled, "{'messageText':'Hello}" as payLoad
insert into operation;

By doing so, we have put event from trigger in Plan 1 in to a event stream
and consume that event stream from Plan 2. After receiving the event
through event stream carbon context initialized properly for the event and
hence our siddhi extension worked as expected.

Thanks & Regards,
/charithag

On Fri, Nov 17, 2017 at 11:09 AM, Charitha Goonetilleke <[email protected]>
wrote:

> Hi Analytics team,
>
> I have wrote a siddhi extension to retrieve devices of user and an
> execution plan with that extension as follows:
>
> @Export('org.wso2.iot.operation:1.0.0')
> define stream operation (meta_deviceIdentifiers string, meta_deviceType
> string, code string, type string, isEnabled bool, payLoad string);
>
> define trigger cronTriggerStream at '0 * * ? * *' ;
>
> from cronTriggerStream
> select device:getDevicesOfUser("admin", "android") as
> meta_deviceIdentifiers, "android" as meta_deviceType, "NOTIFICATION" as
> code, "PROFILE" as type, true as isEnabled, "{'messageText':'Hello'}" as
> payLoad
> insert into operation;
>
> device:getDevicesOfUser extension supposed to retrieve device ids of the
> user. Internal logic in this execution plan does have getting tenant id
> from the privilege carbon context. However when this extension get called
> as above with using a trigger instead of external event, it doesn't set the
> tenant id which running the execution plan, in to privilege carbon context.
> When I debugged the code, I have found tenant id as -1.
>
> Do we need to do any additional things to make trigger in execution plan
> to be aware with the tenant which it is running?
>
> Thanks & regards,
> /charithag
> --
> *Charitha Goonetilleke*
> Senior Software Engineer
> WSO2 Inc.; http://wso2.com
> lean.enterprise.middleware
>
> mobile: +94 77 751 3669 <%2B94777513669>
> Twitter:@CharithaWs <https://twitter.com/CharithaWs>, fb: charithag
> <https://www.facebook.com/charithag>, linkedin: charithag
> <http://www.linkedin.com/in/charithag>
>
> <http://wso2.com/signature>
>



-- 
*Charitha Goonetilleke*
Senior Software Engineer
WSO2 Inc.; http://wso2.com
lean.enterprise.middleware

mobile: +94 77 751 3669 <%2B94777513669>
Twitter:@CharithaWs <https://twitter.com/CharithaWs>, fb: charithag
<https://www.facebook.com/charithag>, linkedin: charithag
<http://www.linkedin.com/in/charithag>

<http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to