<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16735" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>The life cycle of the command service is under user 
control, so you can decide yourself when to create / dispose a command 
service.&nbsp; A&nbsp;possible use case would be to create the service once and 
let it handle all requests and only dispose if you want to take it down.&nbsp; 
You are apparently creating one session per process instance, and disposing it 
after the process instance has been completed, which is&nbsp;also possible if 
that is what you want.&nbsp; So the question on when to dispose a session is 
more about how long you would like to reuse the session.&nbsp; Note that 
creating a new session from an existing rulebase is light-weight, so you 
shouldn't be too afraid&nbsp;from creating multiple session and disposing once 
in a while.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Kris</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=michalbali@gmail.com href="mailto:michalbali@gmail.com">Michal 
  Bali</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=rules-users@lists.jboss.org 
  href="mailto:rules-users@lists.jboss.org">Rules Users List</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, December 02, 2008 10:24 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [rules-users] Proper 
  termination of a CommandService</DIV>
  <DIV><BR></DIV>Thank you Kris ! That is perfect.<BR>
  <DIV><BR></DIV>
  <DIV>I was a bit worried If I was asking wrong questions, since I wasn't 
  getting any answers. &nbsp;</DIV>
  <DIV><BR></DIV>
  <DIV>I have a follow up question though :)<BR><BR>I have an asynchronous 
  ruleflow (by asynchronous I mean ruleflow that has some asynchronous nodes 
  like a human task). Would it be OK to register a afterRuleFlowCompleted 
  RuleFlowEventListener and dispose the session (that contains an instance of 
  this asynchronous ruleflow) there? What is the recommended way to dispose this 
  session? I guess same questions applies to a CommandService (where is the best 
  place to call commandService.dispose() method?).<BR><BR>Best 
  Regards,<BR>Michal<BR></DIV>
  <DIV><BR><BR>
  <DIV class=gmail_quote>On Tue, Dec 2, 2008 at 4:31 PM, Kris Verlaenen <SPAN 
  dir=ltr>&lt;<A href="mailto:kris.verlaenen@cs.kuleuven.be" 
  target=_blank>kris.verlaenen@cs.kuleuven.be</A>&gt;</SPAN> wrote:<BR>
  <BLOCKQUOTE class=gmail_quote 
  style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
    <DIV bgcolor="#ffffff">
    <DIV><FONT face=Arial size=2>Michal,</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>I'll add a dispose method to the 
    SingleSessionCommandService.&nbsp; Don't think using a command for this 
    would be a good idea as it would leave the session in a disposed state so 
    future commands would fail.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Regarding your earlier question, 
    SingleSessionCommandService now also has constructors that allow you to pass 
    in a PlaceholderResolverStrategyFactory.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Kris</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <BLOCKQUOTE 
    style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
      <DIV>
      <DIV></DIV>
      <DIV>
      <DIV 
      style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal">----- 
      Original Message ----- </DIV>
      <DIV 
      style="BACKGROUND: rgb(228,228,228); FONT: 10pt arial; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial"><B>From:</B> 
      <A title=michalbali@gmail.com href="mailto:michalbali@gmail.com" 
      target=_blank>Michal Bali</A> </DIV>
      <DIV 
      style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><B>To:</B> 
      <A title=rules-users@lists.jboss.org 
      href="mailto:rules-users@lists.jboss.org" target=_blank>Rules Users 
      List</A> </DIV>
      <DIV 
      style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><B>Sent:</B> 
      Tuesday, December 02, 2008 1:24 AM</DIV>
      <DIV 
      style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><B>Subject:</B> 
      [rules-users] Proper termination of a CommandService</DIV>
      <DIV><BR></DIV>Hello,<BR>Let's say I have some implementation of a 
      CommandService (for example StatefulSessionCommandService). After I finish 
      working with this CommandService, I want to correctly 'destroy' this 
      object. Since it contains a stateful rule session, I believe this session 
      needs to be disposed. What is the right way to do it?<BR><BR>I was 
      thinking about implementing a DisposeCommand that will simply call 
      session.dispose() in its execute method. Is this a valid 
      solution?<BR><BR>Best Regards,<BR>Michal<BR></DIV></DIV>
      <P></P>
      <HR>

      <P></P>_______________________________________________<BR>rules-users 
      mailing list<BR><A href="mailto:rules-users@lists.jboss.org" 
      target=_blank>rules-users@lists.jboss.org</A><BR><A 
      href="https://lists.jboss.org/mailman/listinfo/rules-users" 
      target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR>
      <P></P></BLOCKQUOTE></DIV><BR>_______________________________________________<BR>rules-users 
    mailing list<BR><A href="mailto:rules-users@lists.jboss.org" 
    target=_blank>rules-users@lists.jboss.org</A><BR><A 
    href="https://lists.jboss.org/mailman/listinfo/rules-users" 
    target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR><BR></BLOCKQUOTE></DIV><BR></DIV>
  <P>
  <HR>

  <P></P>_______________________________________________<BR>rules-users mailing 
  list<BR>rules-users@lists.jboss.org<BR>https://lists.jboss.org/mailman/listinfo/rules-users<BR></BLOCKQUOTE></BODY></HTML>