<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">jdepaul,<DIV><BR class="khtml-block-placeholder"></DIV><DIV> We are implementing a diferent solution for that. We are using a Topic JMS using spring, so we have build diferent RuleBases and publish them</DIV><DIV>in this topicJMS as a post, then a WorkingMemoryFactory has a listener for changes on the topics, and when that happens the factory refresh the</DIV><DIV>singleton reference to the RuleBase (sincronyzed) and provides a newWorkingMemory... no maps, one factory for each rulebase (we have them identified)</DIV><DIV>and the diferent ruleBases are managed by diferent topic-beans-names in the spring configuration. I guess it can be managed by maps too.</DIV><DIV>We will send the code in 3 weeks when we have it tested and operative.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Good luck!.</DIV><DIV><BR><DIV><DIV>On 13-03-2007, at 19:32, Michael Neale wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite">in your case - as you are swapping out the RuleBase - I woudl suggest locking or syncing things when swapping - not sure how to do that given that spring is in control.<BR><BR>Also, i would suggest you use RuleBase#newWorkingMemory(false) so that it doesn't keep a weakhashmap around pointint back to the working memories, as you don't need it (it will mean less big GC pauses under heavy load in your case). <BR><BR>Michael.<BR><BR><DIV><SPAN class="gmail_quote">On 3/13/07, <B class="gmail_sendername">jdepaul</B> <<A href="mailto:jjdepaul@us.ibm.com">jjdepaul@us.ibm.com</A>> wrote:</SPAN><BLOCKQUOTE class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <BR>I know the threading topic has been discussed quite extensively, but I still<BR>need some guidance in the following case:<BR><BR>My application has a RuleManager object that maintains references to many<BR>RuleBase objects in a HashMap. I'm using Spring Framework to wire the bean <BR>relationships together.<BR><BR>The RulesManager is typically busy servicing client requests for instances<BR>of WorkingMemory objects which it fetches from the individual RuleBase<BR>objects it maintains in its Hash ( wm.newWorkingMemory() ).<BR><BR>>From time to time, I'll need RulesManager to reaload the rules that are<BR>associated with the individual RuleBase object - for that, I'm going to<BR>create a new instance of the RuleBase object and then I need an efficient <BR>and safe way to 'swap' this new RuleBase object for the old object reference<BR>in the RulesManager's map.<BR><BR>My question is: should I synchronize the getWorkingMemory(..) method inside<BR>my RulesManager object that uses the hashmap, AND also synchronize the code <BR>that does the object swap - would that be sufficient?! How would I do it<BR>using Collections.synchronizedMap() - remember that I don't have that much<BR>control over the creation of the Map since Spring controls that part of <BR>populating hashmap at startup.<BR><BR>The critical factors for me are speed and efficiency in servicing regular<BR>client requests for WorkingMemory - ideally, I'd synchronize only the method<BR>that does the object swap, but I'm sure that may have some bad <BR>consequences... though as long as I can avoid the race condition I could<BR>probably live with it.<BR><BR>Thanks in advance for ideas -<BR>--<BR>View this message in context: <A href="http://www.nabble.com/Question-on-data-safety-and-threading...-tf3396050.html#a9454823"> http://www.nabble.com/Question-on-data-safety-and-threading...-tf3396050.html#a9454823</A><BR>Sent from the drools - user mailing list archive at <A href="http://Nabble.com">Nabble.com</A>.<BR><BR>_______________________________________________ <BR>rules-users mailing list<BR><A href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A><BR><A href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users </A><BR></BLOCKQUOTE></DIV><BR><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">rules-users mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</A></DIV> </BLOCKQUOTE></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV><SPAN class="Apple-style-span" style="text-decoration: underline;; -khtml-text-decorations-in-effect: underline; "><SPAN class="Apple-style-span" style="-khtml-text-decorations-in-effect: underline; "> </SPAN></SPAN><DIV><FONT class="Apple-style-span" size="3"><SPAN class="Apple-style-span" style="font-size: 13px;"><B style="font-size: 13px; font-weight: bold; "><SPAN class="Apple-style-span" style="font-size: 13px; font-weight: bold; ">Felipe Piccolini M.</SPAN></B></SPAN></FONT></DIV><DIV><A href="mailto:felipe.piccolini@bluesoft.cl"><SPAN class="Apple-style-span" style="color: rgb(0, 0, 238); -khtml-text-decorations-in-effect: underline; ">felipe.piccolini@bluesoft.cl</SPAN></A></DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></DIV></BODY></HTML>