<br><font size=2 face="Trebuchet MS">Hi Vijay,</font>
<br><font size=2 face="Trebuchet MS">Thanks for your reply.</font>
<br><font size=2 face="Trebuchet MS">The problem is that object that I
am inserting it into the session object is NOT serializable, as you know
HttpServletRequest object is not serializable.</font>
<br><font size=2 face="Trebuchet MS">So because of this I am not able to
store this object into the database.</font>
<br><font size=2 face="Trebuchet MS">So that's why I am asking how can
i do this if my object is not serilizable.</font>
<br>
<br>
<br><font size=2 face="Trebuchet MS">Thanks & Regards<br>
<br>
Pardeep Ruhil<br>
nt (s) If you are not the intended recipient, please do not use or disseminate
the information, notify the sender and delete it from your system. </font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="Trebuchet MS"><b>Vijay K Pandey <VPandey@mdes.ms.gov></b>
</font>
<p><font size=1 face="Trebuchet MS">11/18/2009 10:56 PM</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="Trebuchet MS">To</font></div>
<td><font size=1 face="Trebuchet MS">"Pardeep.Ruhil@lntinfotech.com"
<Pardeep.Ruhil@lntinfotech.com>, "rules-users@lists.jboss.org"
<rules-users@lists.jboss.org></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="Trebuchet MS">cc</font></div>
<td><font size=1 face="Trebuchet MS">"kris.verlaenen@cs.kuleuven.be"
<kris.verlaenen@cs.kuleuven.be></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="Trebuchet MS">Subject</font></div>
<td><font size=1 face="Trebuchet MS">RE: [rules-users] Drools Flow :Persistence
Problem : Restore StatefulKnowledgeSession from database</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2 color=#000080 face="Arial">You have to load the same ‘<b>StatefulKnowledgeSession</b>’
in which you have inserted your objects</font><font size=2 face="Courier New">.
</font><font size=2 color=#000080 face="Arial">The inserted objects are
serialized and stored in the column “<b>rules_byte_array</b>” of the
<b>session_info</b> table. </font>
<br><font size=2 color=#000080 face="Arial"> </font>
<br><font size=2 color=#000080 face="Arial">So you have to load the same
session – to get to your inserted objects. </font>
<br><font size=2 color=#000080 face="Arial"> </font>
<br><font size=2 color=#000080 face="Arial">There is a difference the way
process map objects are handled – such as</font>
<br><font size=2 color=#000080 face="Arial"> </font>
<br><font size=2 face="Courier New"> Map<String,
Object> parameters = </font><font size=2 color=#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New">
HashMap<String, Object>();</font>
<br><font size=2 face="Courier New"> parameters.put(</font><font size=2 color=#4200ff face="Courier New">"x"</font><font size=2 face="Courier New">,
</font><font size=2 color=#4200ff face="Courier New">"hello"</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New"> parameters.put(</font><font size=2 color=#4200ff face="Courier New">"y"</font><font size=2 face="Courier New">,
</font><font size=2 color=#4200ff face="Courier New">"hey I am y"</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New"> ksession.startProcess(
</font><font size=2 color=#4200ff face="Courier New">"myprocess"</font><font size=2 face="Courier New">,
parameters );</font>
<br><font size=2 color=#000080 face="Arial"> </font>
<br><font size=2 color=#000080 face="Arial">In the above case the parameters
are not stored as part of the “session info” table. These are stored
separately like in “process instance info” table + (some/other tables
if you use variable persistence strategy)– so if you don’t have the rules
which are based on the objects you are inserting – you can get the same
done through process parameters in which case you can get hold of the process
instance through any new session or the same session and then its
parameters.</font>
<br><font size=2 color=#000080 face="Arial"> </font>
<br><font size=2 color=#000080 face="Arial">Vijay</font>
<div align=center>
<br>
<hr></div>
<br><font size=2 face="Tahoma"><b>From:</b> Pardeep.Ruhil@lntinfotech.com
[mailto:Pardeep.Ruhil@lntinfotech.com] <b><br>
Sent:</b> Wednesday, November 18, 2009 12:38 AM<b><br>
To:</b> rules-users@lists.jboss.org<b><br>
Cc:</b> kris.verlaenen@cs.kuleuven.be; Vijay K Pandey<b><br>
Subject:</b> Re: [rules-users] Drools Flow :Persistence Problem : Restore
StatefulKnowledgeSession from database</font>
<br><font size=3 face="Times New Roman"> </font>
<br><font size=2 face="Trebuchet MS"><br>
Hi Kris,</font><font size=3 face="Times New Roman"> </font><font size=2 face="Trebuchet MS"><br>
Thanks for you valuable input and Vijay of course clearing some of my doubts
by asking question on this.</font><font size=3 face="Times New Roman">
<br>
</font><font size=2 face="Trebuchet MS"><br>
Much of my doubt are clear except one. <br>
When we are reloading the StatefulKnowledgeSession from the database using
the below line</font><font size=3 face="Times New Roman"> </font><font size=2 face="Courier New"><br>
</font><font size=3 face="Times New Roman"> </font><font size=2 face="Courier New"><br>
StatefulKnowledgeSession loadSession= JPAKnowledgeService.<i>loadStatefulKnowledgeSession</i>(id,
</font><font size=2 color=#0021bf face="Courier New"><i>kbase</i></font><font size=2 face="Courier New">,
</font><font size=2 color=#820040 face="Courier New"><b>null</b></font><font size=2 face="Courier New">,
</font><font size=2 color=#0021bf face="Courier New"><i>env</i></font><font size=2 face="Courier New">);</font><font size=3 face="Times New Roman">
<br>
</font><font size=2 face="Trebuchet MS"><br>
This session object is different from the one that is created when we first
created <br>
StatefulknowledgeSession object using </font><font size=3 face="Times New Roman"><br>
</font><font size=2 face="Courier New"><br>
StatefulKnowledgeSession <b>initialSession</b>= JPAKnowledgeService.<i>newStatefulKnowledgeSession</i>(</font><font size=2 color=#0021bf face="Courier New"><i>kbase</i></font><font size=2 face="Courier New">,
</font><font size=2 color=#820040 face="Courier New"><b>null</b></font><font size=2 face="Courier New">,
</font><font size=2 color=#0021bf face="Courier New"><i>env</i></font><font size=2 face="Courier New">);</font><font size=3 face="Times New Roman">
<br>
</font><font size=2 face="Trebuchet MS"><br>
Am I right ?</font><font size=3 face="Times New Roman"> <br>
</font><font size=2 face="Trebuchet MS"><br>
Now In my case I have a <b>HumanWorkItemHandler</b> class for handling
the <b>humantask</b> and there is<b> ActionWorkITemHandle</b>r for my customAction
workItem, which both are initailsed with the <b>initialSession </b>object.</font><font size=3 face="Times New Roman">
</font><font size=2 face="Trebuchet MS"><br>
Now when I load the session from the database to complete the HumanWorkItemHandler
task I got a different session object i.e. <b>loadSession. </b><br>
Now when I insert something in the loadsession using <b>loadSession.insert(request);</b>
So that I can use the same in ActionWorkItemHandler to exceute the action
for the request. <br>
I am not able to retrieve the same request object i.e. (HttpServletRequest)
from the session in ActionWorkItemHandler <br>
as when i do <br>
Collection obj = loadSession.getObject();</font><font size=3 face="Times New Roman">
</font><font size=2 face="Trebuchet MS"><br>
I get request as <b>null. </b> Because this loadSession is different
from the one I have inserted.</font><font size=3 face="Times New Roman">
<br>
</font><font size=2 face="Trebuchet MS"><br>
Kindly help in this, or I have misunderstood the concept. </font><font size=3 face="Times New Roman"><br>
</font><font size=2 face="Trebuchet MS"><br>
Thanks & Regards<br>
<br>
Pardeep Ruhil</font><font size=3 face="Times New Roman"><br>
<br>
</font>
<p>
<table width=100%>
<tr valign=top>
<td width=33%><font size=1 face="Trebuchet MS"><b>Kris Verlaenen <kris.verlaenen@cs.kuleuven.be></b>
</font>
<p><font size=1 face="Trebuchet MS">11/17/2009 04:17 PM</font><font size=3 face="Times New Roman">
</font>
<td width=66%>
<br>
<table width=100%>
<tr valign=top>
<td width=6%>
<div align=right><font size=1 face="Trebuchet MS">To</font></div>
<td width=93%><font size=1 face="Trebuchet MS">Rules Users List <rules-users@lists.jboss.org>,
Vijay K Pandey <VPandey@mdes.ms.gov></font><font size=3 face="Times New Roman">
</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="Trebuchet MS">cc</font></div>
<td><font size=1 face="Trebuchet MS">"Pardeep.Ruhil@lntinfotech.com"
<Pardeep.Ruhil@lntinfotech.com></font><font size=3 face="Times New Roman">
</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="Trebuchet MS">Subject</font></div>
<td><font size=1 face="Trebuchet MS">Re: [rules-users] Drools Flow :Persistence
Problem : Restore StatefulKnowledgeSession from database</font></table>
<br><font size=3 face="Times New Roman"> </font>
<p>
<br>
<table>
<tr valign=top>
<td><font size=3 face="Times New Roman"> </font>
<td><font size=3 face="Times New Roman"> </font></table>
<br></table>
<br><font size=3 face="Times New Roman"><br>
<br>
</font><font size=2 face="Courier New"><br>
Preferably you should cache the session itself as well (so you don't<br>
have to recreate it all the time) and reuse that across you application.<br>
Or you could have multiple independent sessions as well. If you
store<br>
the key of the session somewhere, you can easily restore this session<br>
(or sessions) after failure.<br>
<br>
Kris<br>
<br>
Quoting Vijay K Pandey <VPandey@mdes.ms.gov>:<br>
<br>
> Let's say where we don't need timers - in those cases one can create<br>
> (create only if its not there) a global session (create the<br>
> sessioninfo at the drools startup - store the session primary key<br>
> somewhere) - reuse this session across everywhere?<br>
> <br>
> Vijay<br>
> -----Original Message-----<br>
> From: rules-users-bounces@lists.jboss.org<br>
> [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Kris<br>
> Verlaenen<br>
> Sent: Monday, November 16, 2009 5:12 PM<br>
> To: Rules Users List; Pardeep.Ruhil@lntinfotech.com<br>
> Subject: Re: [rules-users] Drools Flow :Persistence Problem : Restore<br>
> StatefulKnowledgeSession from database<br>
> <br>
> Pardeep,<br>
> <br>
> The behavior you are describing is indeed correct. The session
in<br>
> this<br>
> case is a global session, meaning that it will be used for all<br>
> process<br>
> instances. Note however that, unless you are using timers, all<br>
> other<br>
> state (process instance state, work items, etc.) is persisted<br>
> separately<br>
> and the session state will basically be empty.<br>
> <br>
> It is also possible to have one session per process instance (or<br>
> whatever partitioning you like). A session has a unique id (which<br>
> you<br>
> can specify when reloading the session). You'll then have to
load<br>
> the<br>
> right session before continuing the execution of your process<br>
> instance.<br>
> <br>
> Kris<br>
> <br>
> Quoting Pardeep.Ruhil@lntinfotech.com:<br>
> <br>
> > Hi Salaboy,<br>
> > Thanks for you replying.<br>
> > Yes, of course it is storing multiple process instance Id in
the<br>
> > database.<br>
> > But, what I feel is that it will fail when I am trying to run
two<br>
> > workflow<br>
> > at the same time simultaneously, using the same code by<br>
> dynamically<br>
> > providing the workflow name and the parameters for each of them.<br>
> > Ideally there should be two entries for the<br>
> StatfulKnowledgeSession<br>
> > object<br>
> > because when I try to load the StatefulKnowledgeSession object<br>
> from<br>
> > the<br>
> > database it will give me the session object of the workflow which<br>
> is<br>
> > last<br>
> > executed.<br>
> ><br>
> > For example lets suppose I have two workflow 1 and 2 having
two<br>
> > humantask<br>
> > in each of them . So when I finish the first Human Task of both<br>
> > workflow<br>
> > one by one. SessionInfo present in the database is
of workflow 2<br>
> > (if 2<br>
> > is executed last). Because there is no field in the sessioninfo<br>
> > entity of<br>
> > the database regarding to which workflow it belongs to. Am I
right<br>
> ?<br>
> > So when I try to finish the 1st workflow by executing the
2nd<br>
> > humantask<br>
> > left in it , I need to reload the StatfulKnowledgeSession object<br>
> from<br>
> > the<br>
> > database. As there is no way of distinguishing that the session<br>
> > object<br>
> > store in the database is of which workflow , there might be a<br>
> problem<br>
> > as I<br>
> > may get the ksession object of 2nd workflow.<br>
> ><br>
> > In case of Process Instance it is fine , because there is a field<br>
> > 'processId' which will distinguish which processInstanceId belongs<br>
> to<br>
> ><br>
> > which worklowId or processId.<br>
> > But in case of Session , there is noting as such.<br>
> > I don't what I am saying is handled in drools persistence. Please<br>
> let<br>
> > me<br>
> > know if it there or not.<br>
> ><br>
> > Thanks & Regards<br>
> ><br>
> > Pardeep Ruhil<br>
> ><br>
> ><br>
> ><br>
> ______________________________________________________________________<br>
> <br>
> <br>
> <br>
> <br>
> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm<br>
> _______________________________________________<br>
> rules-users mailing list<br>
> rules-users@lists.jboss.org<br>
> https://lists.jboss.org/mailman/listinfo/rules-users<br>
> _______________________________________________<br>
> rules-users mailing list<br>
> rules-users@lists.jboss.org<br>
> https://lists.jboss.org/mailman/listinfo/rules-users<br>
> <br>
<br>
<br>
<br>
<br>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm<br>
<br>
______________________________________________________________________</font><font size=3 face="Times New Roman"><br>
<br>
<br>
______________________________________________________________________</font>
<p><font size=3><br>
______________________________________________________________________</font>
<p>
<BR>
______________________________________________________________________<BR>