[rules-users] Drools - is dynamic change possible ?
pns77
pnsrapuram at gmail.com
Fri Aug 17 04:43:36 EDT 2007
Hi,
The following is the block of code that i tried
RuleBase ruleBase = readRule();
WorkingMemory workingMemory =
ruleBase.newStatefulSession(false); // to keep reference
// Create a message object
workingMemory.insert( message );
workingMemory.fireAllRules();
When i try chaning the "drl" file at run time the change doesnt get
reflected. Is there anything else i need to be doing here? Any additional
jar files ?
To have this change take effect at runtime - do i need to create a new
session for each run or do i need to retain the session - i tried both
"newStatefulSession(false)" and "newStatefulSession()" - get the same result
with both.
Just to add on...for two successive runs, the times taken to create RuleBase
object were
<<<<<<<< START >>>>>>>>>>1187339950422
<<<<<<<<<< FINISH >>>>>>>>>>>>>>>>.1187339956100 => ~ 6 seconds
<<<<<<<< START >>>>>>>>>>1187340049090
<<<<<<<<<< FINISH >>>>>>>>>>>>>>>>.1187340049721 => ~ .6 seconds
Doesnt this mean that there is a cache that prevents the modified drl file
from being parsed ?
Mark Proctor wrote:
>
> Yes this can be done at runtime. The RuleBase has a reference to each of
> the created StatefulSessions that has not called dispose() yet and will
> push those rule changes out to each running session.
>
>
> Mark
> pns77 wrote:
>> Thanks for the response.
>>
>> Just to confirm when you say "...but you can remove a rule and add
>> another
>> in its place..." - can this be done at runtime - i.e server is running, i
>> go
>> add a new rule/change the output of an existing rule. If so, can i have
>> the
>> new rule take effect ?
>>
>> Also, do i need to include any specific jar file for this dynamic feature
>> ?
>>
>> Am not looking at performance here - more from a
>> maintenance/changeability
>> point of view.
>>
>>
>> Mark Proctor wrote:
>>
>>> you cannot change an individual rule, but you can remove a rule and add
>>> another in its place.
>>>
>>> Mark
>>> pns77 wrote:
>>>
>>>> Have been able to execute/run a sample Drools file
>>>>
>>>> import com.sample.Message;
>>>>
>>>> rule "Hello World"
>>>> when
>>>> m : Message( status == Message.HELLO, message : message,
>>>> testStringExternal : testStringExternal )
>>>> then
>>>> System.out.println( message );
>>>> m.setMessage( "Goodbye cruel world" );
>>>> System.out.println( testStringExternal + "Message.HELLO" );
>>>> m.setStatus( Message.GOODBYE );
>>>> update( m );
>>>> end
>>>>
>>>> Now, is it possible to change the logic dynamically at runtime ? Or is
>>>> the
>>>> drl file used only to externalize the business logic? I tried changing
>>>> the
>>>> message in drl file and it didnt get reflected
>>>>
>>>> Environment - RAD 6.0/jdk 1.4
>>>>
>>>> Used the following set of jar files
>>>> C:\Drools\libraries\drools-core.jar;
>>>> C:\Drools\libraries\drools-compiler.jar;
>>>> C:\Drools\libraries\mvel14.jar;
>>>> C:\Drools\libraries\antlr-runtime.jar;
>>>> C:\Drools\libraries\xstream.jar;
>>>> C:\Drools\lib\core-3.2.3.v_686_R32x.jar;
>>>>
>>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>>
>>
>>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
View this message in context: http://www.nabble.com/Drools---is-dynamic-change-possible---tf4277622.html#a12195188
Sent from the drools - user mailing list archive at Nabble.com.
More information about the rules-users
mailing list