We are making Storm application, there we need to create rule file for each user.it is possible or not?
Asked
Active
Viewed 151 times
1 Answers
1
Yes , you can create the rule file based on user.
Me also done some R&D on this user based rule generation , in my scenario i have created the rule file as same as device_id , whenever i am getting the packet with that user i am loading the rule file with that name in the bolt.
Bolt:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
try {
kbuilder.add(ResourceFactory.newInputStreamResource(new FileInputStream(new File("C:/IotHub/conf/"+deviceID))), ResourceType.DRL );
} catch (FileNotFoundException e) {
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
//
StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
ksession.execute(bean);
In my scenario , deviceId is the rule file name of that device
bean - is your java bean

Mahabaleshwar
- 227
- 1
- 13
-
yes i got idea but my question is there is no device id.where i need to call rule file in Storm in spout,bolt or topology? – Rahul Pandey Dec 02 '16 at 12:06
-
Not spout , there are two way is there:1.you can load the drl in the bolt constructor 2.You can load in the bolt class as i mentioned above. – Mahabaleshwar Dec 02 '16 at 12:23
-
thanks a lot sir for giving reply now i got idea, i will do it. – Rahul Pandey Dec 02 '16 at 12:57