[rules-users] Is there any limitation about the length of attribute's name when declare type in drl file
Hi all,Is there any limitation about the length of attribute's name when declare type in drl file? I encountered a problem these days, I declared a new type in rule file, when fire rules, it always throw java.lang.ClassCaseException: test.obj cannot be cast to test.obj. As I inspected, this is caused by the length of an attribute's name is too long, it's 35 characters, if I remove this attribute, there's no exception. Following is snippet of my rule file: package testdeclare obj@propertyReactivetype : Stringname : Stringattribute_name_too_long_reach_limitation: Booleanendrule adialect mvelsalience 0no-loopwhen$obj:obj(type == a)thenmodify ($obj) {name = abc};end -- View this message in context: http://drools.46999.n3.nabble.com/Is-there-any-limitation-about-the-length-of-attribute-s-name-when-declare-type-in-drl-file-tp4026171.html Sent from the Drools: User forum mailing list archive at Nabble.com.___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is there any limitation about the length of attribute's name when declare type in drl file
Declares are compiled into java classes, so the only limitations would be posed by the JVM. I tried to run your snippet, but it works fine (you should still follow conventions and use upper case names for the declared types). The CCE you get, moreover, seems to point to a different issue. Could you post a full reproducer, together with details on your environment - Drools version, JVM, OS, etc... Thanks Davide On 09/30/2013 12:13 AM, richie wrote: Hi all, Is there any limitation about the length of attribute's name when declare type in drl file? I encountered a problem these days, I declared a new type in rule file, when fire rules, it always throw *java.lang.ClassCaseException: test.obj cannot be cast to test.obj*. As I inspected, this is caused by the length of an attribute's name is too long, it's 35 characters, if I remove this attribute, there's no exception. Following is snippet of my rule file: | package test declare obj @propertyReactive type : String name : String attribute_name_too_long_reach_limitation: Boolean end rule a dialect mvel salience 0 no-loop when $obj:obj(type == a) then modify ($obj) {name = abc}; end | View this message in context: Is there any limitation about the length of attribute's name when declare type in drl file http://drools.46999.n3.nabble.com/Is-there-any-limitation-about-the-length-of-attribute-s-name-when-declare-type-in-drl-file-tp4026171.html Sent from the Drools: User forum mailing list archive http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] replace session clock at runtime
[SOLUTION] I found a solution/workaround to this problem: I create the session with JPAKnowledgeService.newStatefulKnowledgeSession() and pseudo clock in configuration, feed in my old events - and store the session it a database. When retrieving the session, I can set realtime clock in the configuration with JPAKnowledgeService.loadStatefulKnowledgeSession(). As I am not really interested in storing the sessions, I use an in-memory db like in the documentation (3.3.10. Persistence and Transactions) @Project Team: The documentation (Chapter 3.3.10 / Drools 5.5.0) is really outdated, e.g. the package references in persistence.xml are not correct any more . Also it seems to be a full example, but missing location of files (where to put persistence.xml) and information about general configuration of hibernate and bitronix. (I can see why you omitted it, but it would be helpful) I also don't get why it is impossible to do the same with the SerializeMarshallingStrategy - I am pretty sure that the UnMarshaller also internally sets a new clock configuration and it would be a great feature, if this could be exposed to let developers set their own clock as required. Cheers, Alex On 25.09.2013, at 06:59, Wolfgang Laun wolfgang.l...@gmail.com wrote: Setting the clock is a session configuration option, which means that it has to be set at session instantiation time. You might try to continue to use the pseudo-clock until you have finished the replay and mimick the realtime clock with it, although it might need some experimenting to learn when and how to advance the pseudo-clock: before and/or after insertions, every n ms,... -W On 24/09/2013, amarok m...@alexander-wolf.net wrote: I am still stuck with this. Is there any way to replay events into a session and then getting into realtime mode? amarok wrote Drools 5.5 Hey guys, Is it possible to replace the session clock of an existing stateful knowledge session (STREAM mode) while it is running or at least by pausing and restarting it? I need to feed old events into the session to restore a certain session state before switching the sessions to realtime mode and continue with new incoming events... A code snippet would make me very happy ;) - Alex ___ rules-users mailing list rules-users@.jboss https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-replace-session-clock-at-runtime-tp4026090p4026112.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users signature.asc Description: Message signed with OpenPGP using GPGMail ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] FW: Implementation of my use case - what am I doing wrong?
I wrote my question in the past, but now I want to ask about another strange behavior I have encountered. I will rewrite all relevant data. I am trying to identify a port scan event: Basic event is connection log. For each combination of source_ip and destination_ip, detect a port scan event, if over 5 seconds there were more than 2 connection logs with different ports . The event will stay open for 10 seconds and an update will be sent for any new port detected. Every update will contain the count of connection logs combining it and their id (marker). This is my drl file: package test; import correlation.impl.drools.Log import correlation.impl.drools.CorrelatedEvent global correlation.server.EventsHandler externalEventsHandler; declare Log @role( event) end declare CorrelatedEvent //@propertyReactive @role( event) @timestamp( getTimestamp()) @expires( 10s ) @duration( getDuration() ) end // this rule will create a Port Scan event if none exist for this group-by values rule Create Port Scan Event dialect java//dialect can be either mvel or java for the RHS (only java dialect support generic containers) no-loop//this means - do not revaluate rules if the events were altered in memory when $log : Log() accumulate( Log( this after[0s,5s] $log, fieldsMap.get(src) == $log.fieldsMap.get(src) , fieldsMap.get(dst) == $log.fieldsMap.get(dst), $port : fieldsMap.get(port)); $portSet : collectSet($port); $portSet.size 2 ) accumulate( Log( this after[0s,5s] $log, fieldsMap.get(src) == $log.fieldsMap.get(src) , fieldsMap.get(dst) == $log.fieldsMap.get(dst) , $portSet.contains(fieldsMap.get(port)) , $marker : fieldsMap.get(marker)); $markerSet : collectSet($marker)) not CorrelatedEvent(getName() == portScan , fieldsMap.get(src) == $log.fieldsMap.get(src) , fieldsMap.get(dst) == $log.fieldsMap.get(dst)) then CorrelatedEvent $ce = new CorrelatedEvent(); $ce.setName(portScan); $ce.setEventsHandler(externalEventsHandler); $ce.setDurationInSec(10); $ce.fieldsMap.put(src, $log.fieldsMap.get(src)); $ce.fieldsMap.put(dst, $log.fieldsMap.get(dst)); $ce.endUpdate($markerSet, $portSet); insert($ce); end rule Create Port Scan Event - update dialect java//dialect can be either mvel or java for the RHS (only java dialect support generic containers) no-loop when $ce: CorrelatedEvent(getName() == portScan, $portSet: getUniqueSet()) $log: Log(fieldsMap.get(src) == $ce.fieldsMap.get(src) , fieldsMap.get(dst) == $ce.fieldsMap.get(dst) , !$portSet.contains(fieldsMap.get(port)), this after $ce.getStartTime() , this before $ce.getEndTime()) then modify( $ce ) {endUpdate($log.fieldsMap.get(marker).toString(), $log.fieldsMap.get(port))} end I test it like this: I insert a connection log and fire the rules every second. I have 25 logs with the same src and dst, but each has different (serial) port and marker. So after 12-13 logs, I expect to identify a new event with another consecutive 3 logs. In each rule's RHS, I print the rule fired and the ports accumulated so far. With existing implementation, I see the following output at 14th second: rule fired: Create Port Scan Event - update portSet: [1, 7, 11, 8, 5, 6, 3, 10, 4, 9, 12, 2] rule fired: Create Port Scan Event portSet: [13, 11, 12] As we can see, the first rule processes logs already processed by the second rule (11,12). After examining the first rule, I thought I understood the reason for this behavior. I changed the order of conditions in the LHS of the first rule by moving not CorrelatedEvent... to be the second condition. But It still behaves the same. Why is that? How can I prevent the first rule from processing logs already processed by the second rule? Thanks a lot! --- Log class: public class Log { public HashMapString, Object fieldsMap = new HashMap(); } --- CorrelatedEvent class: - public class CorrelatedEvent { public MapString, Object fieldsMap; public int duration; //in ms public long timestamp; private String name; private SetString markersSet; private Set uniqueSet; private long logsCount; private Calendar startTime; private Calendar endTime;
[rules-users] Howto obtain collection of all matched events in rule
Dear all, I am looking for a convenient way to obtain all events that lead to the firing of the rule in the then-part of a rule. I know that I can build this collection by explicitly creating a collection and adding all the events listed in the when part, but I am looking for something more convenient. I already discovered that one can access this information in the beforeMatchFired event through getMatch().getObjects(), but I need to access this in the then-part of the rule. How do I obtain the match object there? Best regards, Ingo ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Howto obtain collection of all matched events in rule
Have you considered accumulate and from collect? Or perhaps I misinterpreted the question...? -W On 30/09/2013, IK81 m...@kofler.me wrote: Dear all, I am looking for a convenient way to obtain all events that lead to the firing of the rule in the then-part of a rule. I know that I can build this collection by explicitly creating a collection and adding all the events listed in the when part, but I am looking for something more convenient. I already discovered that one can access this information in the beforeMatchFired event through getMatch().getObjects(), but I need to access this in the then-part of the rule. How do I obtain the match object there? Best regards, Ingo ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] replace session clock at runtime
Alexander, Regarding the clock, to be honest, I think you found a loophole... :) the original design does not allow switching out clocks on an existing session as it is impossible for the engine to guarantee consistency in such case. Additionally, in my experience, real time clocks are usually not the best choice for production applications. They require less code, but in the end, the application has no control over the time flow and can create several situations that will make it impossible for you to obtain the desired results. My suggestion is always to use a pseudo clock and have your application control it based on your desired behaviour. This can be as simple as a thread syncing the clock with the machine clock at predefined intervals, or based on a clock heartbeat event, or based on the streams of events, etc. Thanks for pointing out the docs errors. We will update them for the next release (6.0.0). Also, if you can submit a PR with the update, always happy to apply. Edson On Mon, Sep 30, 2013 at 9:21 AM, Alexander Wolf m...@alexander-wolf.netwrote: [SOLUTION] I found a solution/workaround to this problem: I create the session with JPAKnowledgeService.newStatefulKnowledgeSession() and pseudo clock in configuration, feed in my old events - and store the session it a database. When retrieving the session, I can set realtime clock in the configuration with JPAKnowledgeService.loadStatefulKnowledgeSession(). As I am not really interested in storing the sessions, I use an in-memory db like in the documentation (3.3.10. Persistence and Transactions) @Project Team: The documentation (Chapter 3.3.10 / Drools 5.5.0) is really outdated, e.g. the package references in persistence.xml are not correct any more . Also it seems to be a full example, but missing location of files (where to put persistence.xml) and information about general configuration of hibernate and bitronix. (I can see why you omitted it, but it would be helpful) I also don't get why it is impossible to do the same with the SerializeMarshallingStrategy - I am pretty sure that the UnMarshaller also internally sets a new clock configuration and it would be a great feature, if this could be exposed to let developers set their own clock as required. Cheers, Alex On 25.09.2013, at 06:59, Wolfgang Laun wolfgang.l...@gmail.com wrote: Setting the clock is a session configuration option, which means that it has to be set at session instantiation time. You might try to continue to use the pseudo-clock until you have finished the replay and mimick the realtime clock with it, although it might need some experimenting to learn when and how to advance the pseudo-clock: before and/or after insertions, every n ms,... -W On 24/09/2013, amarok m...@alexander-wolf.net wrote: I am still stuck with this. Is there any way to replay events into a session and then getting into realtime mode? amarok wrote Drools 5.5 Hey guys, Is it possible to replace the session clock of an existing stateful knowledge session (STREAM mode) while it is running or at least by pausing and restarting it? I need to feed old events into the session to restore a certain session state before switching the sessions to realtime mode and continue with new incoming events... A code snippet would make me very happy ;) - Alex ___ rules-users mailing list rules-users@.jboss https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-replace-session-clock-at-runtime-tp4026090p4026112.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli Principal Software Engineer Red Hat Business Systems and Intelligence Group ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Howto obtain collection of all matched events in rule
I already use the accumulate. Perhaps this example of a rule will clarify my issue: when // match a device $d : Device () // if there are more than 5 offline events for that device within the last 15 minutes $x : Number(intValue = 5) from accumulate ( $e : OfflineEvent (deviceId == $d.id) over window:time(15m), count ($e)) $y : SpecialEvent (deviceId == $d.id, code=10) then ... here I need a collection of all events that caused the rule to fire ... this means all accumulated offline events and the special event I registered an AgendaListener and get this kind of collection via the Match object. But how do I access this object directly in the rule? Best Regards, Ingo On 2013-09-30 16:05, Wolfgang Laun wrote: Have you considered accumulate and from collect? Or perhaps I misinterpreted the question...? -W On 30/09/2013, IK81 m...@kofler.me wrote: Dear all, I am looking for a convenient way to obtain all events that lead to the firing of the rule in the then-part of a rule. I know that I can build this collection by explicitly creating a collection and adding all the events listed in the when part, but I am looking for something more convenient. I already discovered that one can access this information in the beforeMatchFired event through getMatch().getObjects(), but I need to access this in the then-part of the rule. How do I obtain the match object there? Best regards, Ingo ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Reevaluate rules on collect
I have the following three rules: rule Create Acct Context when $Acct:Acct() not (exists(AcctContext(Acct ==$Acct))) then insert(new AcctContext($Acct)); end rule Add Acct Statuses to AcctContext no-loop true when $AcctContext:AcctContext($Acct:Acct) $AcctStatuses : List() from collect ( AcctPerformanceStatus(acctId==$Acct.id)) then modify($AcctContext) {addAllAcctStatuses($AcctStatuses) }; end rule Test when AcctContext(getAcctStatus(Test1)!=null) then System.out.println(Good!); end I would expect that after the first 2 rules fire, that my 3rd rule would fire if the data is there successfully(which I have done in my unit test). However the 3rd rule never fires. Any thoughts into how to accomplish this? We are using drools 5.5 so perhaps property reactive? These rules are creating a context/wrapper object to make decision tables easier to write/manage for our business users. Thanks! -- View this message in context: http://drools.46999.n3.nabble.com/Reevaluate-rules-on-collect-tp4026194.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] replace session clock at runtime
Thanks Edson, - What exactly is a PR ? I wouldn't mind helping with the documentation. - how would I declare my own clock implementation in the session configuration? I can't find any example for this. (?) Alex On 30.09.2013, at 16:23, Edson Tirelli ed.tire...@gmail.com wrote: Alexander, Regarding the clock, to be honest, I think you found a loophole... :) the original design does not allow switching out clocks on an existing session as it is impossible for the engine to guarantee consistency in such case. Additionally, in my experience, real time clocks are usually not the best choice for production applications. They require less code, but in the end, the application has no control over the time flow and can create several situations that will make it impossible for you to obtain the desired results. My suggestion is always to use a pseudo clock and have your application control it based on your desired behaviour. This can be as simple as a thread syncing the clock with the machine clock at predefined intervals, or based on a clock heartbeat event, or based on the streams of events, etc. Thanks for pointing out the docs errors. We will update them for the next release (6.0.0). Also, if you can submit a PR with the update, always happy to apply. Edson On Mon, Sep 30, 2013 at 9:21 AM, Alexander Wolf m...@alexander-wolf.net wrote: [SOLUTION] I found a solution/workaround to this problem: I create the session with JPAKnowledgeService.newStatefulKnowledgeSession() and pseudo clock in configuration, feed in my old events - and store the session it a database. When retrieving the session, I can set realtime clock in the configuration with JPAKnowledgeService.loadStatefulKnowledgeSession(). As I am not really interested in storing the sessions, I use an in-memory db like in the documentation (3.3.10. Persistence and Transactions) @Project Team: The documentation (Chapter 3.3.10 / Drools 5.5.0) is really outdated, e.g. the package references in persistence.xml are not correct any more . Also it seems to be a full example, but missing location of files (where to put persistence.xml) and information about general configuration of hibernate and bitronix. (I can see why you omitted it, but it would be helpful) I also don't get why it is impossible to do the same with the SerializeMarshallingStrategy - I am pretty sure that the UnMarshaller also internally sets a new clock configuration and it would be a great feature, if this could be exposed to let developers set their own clock as required. Cheers, Alex On 25.09.2013, at 06:59, Wolfgang Laun wolfgang.l...@gmail.com wrote: Setting the clock is a session configuration option, which means that it has to be set at session instantiation time. You might try to continue to use the pseudo-clock until you have finished the replay and mimick the realtime clock with it, although it might need some experimenting to learn when and how to advance the pseudo-clock: before and/or after insertions, every n ms,... -W On 24/09/2013, amarok m...@alexander-wolf.net wrote: I am still stuck with this. Is there any way to replay events into a session and then getting into realtime mode? amarok wrote Drools 5.5 Hey guys, Is it possible to replace the session clock of an existing stateful knowledge session (STREAM mode) while it is running or at least by pausing and restarting it? I need to feed old events into the session to restore a certain session state before switching the sessions to realtime mode and continue with new incoming events... A code snippet would make me very happy ;) - Alex ___ rules-users mailing list rules-users@.jboss https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-replace-session-clock-at-runtime-tp4026090p4026112.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli Principal Software Engineer Red Hat Business Systems and Intelligence Group ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users signature.asc Description: Message signed with OpenPGP using GPGMail
Re: [rules-users] replace session clock at runtime
Hi Edson, On 30/09/2013, Edson Tirelli ed.tire...@gmail.com wrote: Alexander, Regarding the clock, to be honest, I think you found a loophole... :) the original design does not allow switching out clocks on an existing session as it is impossible for the engine to guarantee consistency in such case. Additionally, in my experience, real time clocks are usually not the best choice for production applications. They require less code, but in the end, the application has no control over the time flow and can create several situations that will make it impossible for you to obtain the desired results. If the application just has to follow suit, whatever the time flow is...? In many apps, it does not have to have control over the flow of time. (It would be nice if we had, wouldn't it ;-) ) My suggestion is always to use a pseudo clock and have your application control it based on your desired behaviour. This can be as simple as a thread syncing the clock with the machine clock at predefined intervals, or based on a clock heartbeat event, or based on the streams of events, etc. So, what's the feature of setting the event's time stamp according to the system's clock meant to achieve if you recommend using pseudo clocks all over? Not that I entirely disagree with you. A well-tuned pseudo-clock may avoid many issues, although there are several issues, e.g., timers, and what is the relationship with the way rules are fired... Cheers Wolfgang Thanks for pointing out the docs errors. We will update them for the next release (6.0.0). Also, if you can submit a PR with the update, always happy to apply. Edson On Mon, Sep 30, 2013 at 9:21 AM, Alexander Wolf m...@alexander-wolf.netwrote: [SOLUTION] I found a solution/workaround to this problem: I create the session with JPAKnowledgeService.newStatefulKnowledgeSession() and pseudo clock in configuration, feed in my old events - and store the session it a database. When retrieving the session, I can set realtime clock in the configuration with JPAKnowledgeService.loadStatefulKnowledgeSession(). As I am not really interested in storing the sessions, I use an in-memory db like in the documentation (3.3.10. Persistence and Transactions) @Project Team: The documentation (Chapter 3.3.10 / Drools 5.5.0) is really outdated, e.g. the package references in persistence.xml are not correct any more . Also it seems to be a full example, but missing location of files (where to put persistence.xml) and information about general configuration of hibernate and bitronix. (I can see why you omitted it, but it would be helpful) I also don't get why it is impossible to do the same with the SerializeMarshallingStrategy - I am pretty sure that the UnMarshaller also internally sets a new clock configuration and it would be a great feature, if this could be exposed to let developers set their own clock as required. Cheers, Alex On 25.09.2013, at 06:59, Wolfgang Laun wolfgang.l...@gmail.com wrote: Setting the clock is a session configuration option, which means that it has to be set at session instantiation time. You might try to continue to use the pseudo-clock until you have finished the replay and mimick the realtime clock with it, although it might need some experimenting to learn when and how to advance the pseudo-clock: before and/or after insertions, every n ms,... -W On 24/09/2013, amarok m...@alexander-wolf.net wrote: I am still stuck with this. Is there any way to replay events into a session and then getting into realtime mode? amarok wrote Drools 5.5 Hey guys, Is it possible to replace the session clock of an existing stateful knowledge session (STREAM mode) while it is running or at least by pausing and restarting it? I need to feed old events into the session to restore a certain session state before switching the sessions to realtime mode and continue with new incoming events... A code snippet would make me very happy ;) - Alex ___ rules-users mailing list rules-users@.jboss https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-replace-session-clock-at-runtime-tp4026090p4026112.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli Principal Software
Re: [rules-users] replace session clock at runtime
Reading your answer again I just realized that you did not recommend to write my own clock implementation. Therefore you may just ignore that question. I am still curious what PR stands for though. Alex On 30.09.2013, at 17:44, Alexander Wolf m...@alexander-wolf.net wrote: Thanks Edson, - What exactly is a PR ? I wouldn't mind helping with the documentation. - how would I declare my own clock implementation in the session configuration? I can't find any example for this. (?) Alex On 30.09.2013, at 16:23, Edson Tirelli ed.tire...@gmail.com wrote: Alexander, Regarding the clock, to be honest, I think you found a loophole... :) the original design does not allow switching out clocks on an existing session as it is impossible for the engine to guarantee consistency in such case. Additionally, in my experience, real time clocks are usually not the best choice for production applications. They require less code, but in the end, the application has no control over the time flow and can create several situations that will make it impossible for you to obtain the desired results. My suggestion is always to use a pseudo clock and have your application control it based on your desired behaviour. This can be as simple as a thread syncing the clock with the machine clock at predefined intervals, or based on a clock heartbeat event, or based on the streams of events, etc. Thanks for pointing out the docs errors. We will update them for the next release (6.0.0). Also, if you can submit a PR with the update, always happy to apply. Edson On Mon, Sep 30, 2013 at 9:21 AM, Alexander Wolf m...@alexander-wolf.net wrote: [SOLUTION] I found a solution/workaround to this problem: I create the session with JPAKnowledgeService.newStatefulKnowledgeSession() and pseudo clock in configuration, feed in my old events - and store the session it a database. When retrieving the session, I can set realtime clock in the configuration with JPAKnowledgeService.loadStatefulKnowledgeSession(). As I am not really interested in storing the sessions, I use an in-memory db like in the documentation (3.3.10. Persistence and Transactions) @Project Team: The documentation (Chapter 3.3.10 / Drools 5.5.0) is really outdated, e.g. the package references in persistence.xml are not correct any more . Also it seems to be a full example, but missing location of files (where to put persistence.xml) and information about general configuration of hibernate and bitronix. (I can see why you omitted it, but it would be helpful) I also don't get why it is impossible to do the same with the SerializeMarshallingStrategy - I am pretty sure that the UnMarshaller also internally sets a new clock configuration and it would be a great feature, if this could be exposed to let developers set their own clock as required. Cheers, Alex On 25.09.2013, at 06:59, Wolfgang Laun wolfgang.l...@gmail.com wrote: Setting the clock is a session configuration option, which means that it has to be set at session instantiation time. You might try to continue to use the pseudo-clock until you have finished the replay and mimick the realtime clock with it, although it might need some experimenting to learn when and how to advance the pseudo-clock: before and/or after insertions, every n ms,... -W On 24/09/2013, amarok m...@alexander-wolf.net wrote: I am still stuck with this. Is there any way to replay events into a session and then getting into realtime mode? amarok wrote Drools 5.5 Hey guys, Is it possible to replace the session clock of an existing stateful knowledge session (STREAM mode) while it is running or at least by pausing and restarting it? I need to feed old events into the session to restore a certain session state before switching the sessions to realtime mode and continue with new incoming events... A code snippet would make me very happy ;) - Alex ___ rules-users mailing list rules-users@.jboss https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-replace-session-clock-at-runtime-tp4026090p4026112.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli Principal Software Engineer Red Hat Business
Re: [rules-users] replace session clock at runtime
On 30/09/2013, Alexander Wolf m...@alexander-wolf.net wrote: Reading your answer again I just realized that you did not recommend to write my own clock implementation. Therefore you may just ignore that question. Indeed: I don't see any other option. Either you follow Time, or you roll your own - which may be based on anything that delivers a suitable value - and that's a pseudo-clock. -W I am still curious what PR stands for though. Alex On 30.09.2013, at 17:44, Alexander Wolf m...@alexander-wolf.net wrote: Thanks Edson, - What exactly is a PR ? I wouldn't mind helping with the documentation. - how would I declare my own clock implementation in the session configuration? I can't find any example for this. (?) Alex On 30.09.2013, at 16:23, Edson Tirelli ed.tire...@gmail.com wrote: Alexander, Regarding the clock, to be honest, I think you found a loophole... :) the original design does not allow switching out clocks on an existing session as it is impossible for the engine to guarantee consistency in such case. Additionally, in my experience, real time clocks are usually not the best choice for production applications. They require less code, but in the end, the application has no control over the time flow and can create several situations that will make it impossible for you to obtain the desired results. My suggestion is always to use a pseudo clock and have your application control it based on your desired behaviour. This can be as simple as a thread syncing the clock with the machine clock at predefined intervals, or based on a clock heartbeat event, or based on the streams of events, etc. Thanks for pointing out the docs errors. We will update them for the next release (6.0.0). Also, if you can submit a PR with the update, always happy to apply. Edson On Mon, Sep 30, 2013 at 9:21 AM, Alexander Wolf m...@alexander-wolf.net wrote: [SOLUTION] I found a solution/workaround to this problem: I create the session with JPAKnowledgeService.newStatefulKnowledgeSession() and pseudo clock in configuration, feed in my old events - and store the session it a database. When retrieving the session, I can set realtime clock in the configuration with JPAKnowledgeService.loadStatefulKnowledgeSession(). As I am not really interested in storing the sessions, I use an in-memory db like in the documentation (3.3.10. Persistence and Transactions) @Project Team: The documentation (Chapter 3.3.10 / Drools 5.5.0) is really outdated, e.g. the package references in persistence.xml are not correct any more . Also it seems to be a full example, but missing location of files (where to put persistence.xml) and information about general configuration of hibernate and bitronix. (I can see why you omitted it, but it would be helpful) I also don't get why it is impossible to do the same with the SerializeMarshallingStrategy - I am pretty sure that the UnMarshaller also internally sets a new clock configuration and it would be a great feature, if this could be exposed to let developers set their own clock as required. Cheers, Alex On 25.09.2013, at 06:59, Wolfgang Laun wolfgang.l...@gmail.com wrote: Setting the clock is a session configuration option, which means that it has to be set at session instantiation time. You might try to continue to use the pseudo-clock until you have finished the replay and mimick the realtime clock with it, although it might need some experimenting to learn when and how to advance the pseudo-clock: before and/or after insertions, every n ms,... -W On 24/09/2013, amarok m...@alexander-wolf.net wrote: I am still stuck with this. Is there any way to replay events into a session and then getting into realtime mode? amarok wrote Drools 5.5 Hey guys, Is it possible to replace the session clock of an existing stateful knowledge session (STREAM mode) while it is running or at least by pausing and restarting it? I need to feed old events into the session to restore a certain session state before switching the sessions to realtime mode and continue with new incoming events... A code snippet would make me very happy ;) - Alex ___ rules-users mailing list rules-users@.jboss https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-replace-session-clock-at-runtime-tp4026090p4026112.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users