[rules-users] replace session clock at runtime

Wolfgang Laun wolfgang.laun at gmail.com
Mon Sep 30 13:14:44 EDT 2013


On 30/09/2013, Alexander Wolf <mail at 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 <mail at 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.tirelli at 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 <mail at 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.laun at 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 <mail at 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 at .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 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
>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at 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 at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>


More information about the rules-users mailing list