javadroolsapache-stormdrools-guvnordrools-fusion

How to create Drools rule file for each user using Apache Storm?


We are making Storm application, there we need to create rule file for each user.it is possible or not?


Solution

  • 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