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
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] 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
Re: [rules-users] replace session clock at runtime
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
Re: [rules-users] replace session clock at runtime
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] replace session clock at runtime
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@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users