[rules-users] dynamic rule creation - from database.

Mark Proctor mproctor at codehaus.org
Wed Mar 26 09:43:04 EDT 2008


You could try the BRMS and the RuleAgent.

Mark
hanumesh.m wrote:
> Hi 
>
>  I need an example of using dynamic rules. Its very urgent. ( I am using
> drools 4.0.3 )
>
>  My application will poll a directory for a file(trade partners will drop
> the file on server), which contains some mask(fileMask) in name which can
> decide on the target Queue where the data of file should be directed to.
>
>  If the trade partners are fixed then there is no problem, I can write .drl
> file(fixed) with one rule for a trade partner and then I can fire the rules
> to decide the target Queue.( .drl content followed )
>
>  But new partners may add up by admin module, (which has details like
> fileMask, toQueue, fromQueue etc. all these details are in database). When a
> new trade partner added then my program should fire a rule for new trade
> partner i.e new rule should be created at runtime(from database) for
> fileMask, toQueue, fromQueue.
>
>  Please suggest how should I write rule at runtime so that adding new
> partner will not require changes in code and redeploy.
>
> Here is .drl
> ----------------------------------------------------------------------
> rule "Process 834"
> 	no-loop 
> 	when
> 		m: Message( fileName matches "^.*834.*$")
> 	then
> 		System.out.println( "Reading Rule for 834 ..." ); 
> 		m.setFromQ("INBOUND.834.EDI");
> 		m.setToQ("INBOUND.834.XML");
> 		m.setProcess("834");
> 		update( m );
> end
>
> rule "Process 850"
> 	no-loop 
> 	when
> 		m: Message( fileName matches "^.*850.*$")
> 	then
> 		System.out.println( "Reading Rule for 850 ..." ); 
> 		m.setFromQ("INBOUND.850.EDI");
> 		m.setToQ("INBOUND.850.XML");
> 		m.setProcess("850");
> 		update( m );
> end
>
> -----------------------------------------------------------------------
> How to avoid writing these static rules and making them dynamic by fetching
> from database.
> I have already posted it but didn't got help so reposting the same again
> hoping to have some luck this time
>
> Thanks in advance,
> Hanumesh
>  
>   




More information about the rules-users mailing list