<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Asynch Save</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Asynch Save</description>
  <pubDate>Thu, 16 Apr 2026 07:56:13 -700</pubDate>
  <lastBuildDate>Thu, 13 Sep 2007 20:56:30 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=429</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Asynch Save : The answer depends on what you&amp;#039;re...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=429&amp;PID=1180#1180</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=21" rel="nofollow">IdeaBlade</a><br /><strong>Subject:</strong> 429<br /><strong>Posted:</strong> 13-Sep-2007 at 8:56pm<br /><br /><DIV><FONT face=Arial size=2><SPAN =062041823-13092007>The answer depends on what you're trying to do.</SPAN></FONT></DIV><DIV><FONT face=Arial size=2><SPAN =062041823-13092007></SPAN></FONT>&nbsp;</DIV><DIV><FONT face=Arial size=2><SPAN =062041823-13092007>As I understand it, your process is something like:</SPAN></FONT></DIV><UL><LI><FONT face=Arial size=2><SPAN =062041823-13092007>get a lot of data</SPAN></FONT> <LI><FONT face=Arial size=2><SPAN =062041823-13092007>modify that data</SPAN></FONT> <LI><FONT face=Arial size=2><SPAN =062041823-13092007>create a lot more data</SPAN></FONT> <LI><FONT face=Arial size=2><SPAN =062041823-13092007>save it all in a single transaction</SPAN></FONT></LI></UL><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>You are suggesting that saving it all could take a long time. Is that because the database takes a long time to do the work? Or because you think it will take a long time to both transmit the data from the client to the server and perform the save.</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>If you think the big hangup is moving data from client to server, is it possible that some of the data can be created/acquired and modified in the middle tier? We see that with audit records for example. I save ten objects each of which kicks out an average of 5 audit records. I don't want those audit records on the client and I certainly don't want to transmit them over a slow connection. But I do need to create them and include them in the transaction. This kind of thing is easily done in the Business Object Server execution space.</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>Now when you do the work in the BOS, the work of each client request is done on its own thread. Therefore, the save process within the&nbsp;BOS is inherently an async save.</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>If the database takes a long time to process the save, you may have to worry about a&nbsp;timeout between the database and the BOS. </FONT></SPAN><SPAN =062041823-13092007><FONT face=Arial size=2>Are you really taxing the database with your save size?&nbsp; Perhaps we need to look at batch update or some similar&nbsp;kind of exceptional save approach; you will want to resort to this expedient only when necessary as it introduces complexity ... but it's there if you need it.</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>&#091;Aside:&nbsp; I'm describing performance tuning techniques that you should draw upon only when you have measured performance and determined that it is unacceptable. Otherwise, we're just introducing complexity that you will have to understand and maintain. I'm sure you know this but it is always worth repeating.&#093;</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>As I said at the top, you can perform a client side async save. That isn't something that comes right out of the DevForce box but it isn't terribly difficult to do (I'll give you a rough outline in a second).</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>What alarms me is the notion that the user can continue working while the data are being saved. What are they working on? Is it the same data that you're saving on a different thread. That is likely to cause concurrency problems later when they try to save their changes; you can resolve these but it could be tricky.</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>Let's suppose that your client side save process was taking care of a basket of work. Once the saving starts,&nbsp;the client turns to a completely new basket of work. The old basket is old news.&nbsp;How might I proceed?</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>In rough, the whole process looks like this:</FONT></SPAN></DIV><UL><LI><SPAN =062041823-13092007><FONT face=Arial size=2>I'll assume that you have a working&nbsp;PersistenceManager (PM) with your changes to save</FONT></SPAN><SPAN =062041823-13092007> <LI><SPAN =062041823-13092007><FONT face=Arial size=2>Instantiate an instance of your "BackgroundSaver" class</FONT></SPAN> <LI><SPAN =062041823-13092007><FONT face=Arial size=2>That BackgroundSaver has a "GetChanges()" method. You can give it the working PM or maybe you cherry pick the objects to save and pass that too it.</FONT></SPAN> <LI><FONT face=Arial><FONT size=2><SPAN =062041823-13092007>The BackgroundSaver internally creates a new, private PM and copies the objects to save. This </SPAN>in-memory&nbsp;<SPAN =062041823-13092007>copy </SPAN>tak<SPAN =062041823-13092007>es</SPAN> no perceptible time<SPAN =062041823-13092007>; there's a single PM method to perform that copy today</SPAN>.</FONT></FONT></SPAN> <LI><SPAN =062041823-13092007><FONT face=Arial size=2>Remove the objects you're saving&nbsp;from the old PM (because you're moving on to a new basket, right?).</FONT></SPAN><SPAN =062041823-13092007> <LI><SPAN =062041823-13092007><FONT face=Arial size=2>Tell the BackgroundSaver to execute.</FONT></SPAN> <LI></SPAN><SPAN =062041823-13092007><FONT face=Arial size=2>It acquires a thread from the ThreadPool and&nbsp;executes the PM.Save() method on its private PM on the&nbsp;background thread</FONT></SPAN> <LI><SPAN =062041823-13092007><FONT face=Arial size=2>Add your own callback method&nbsp;to this mix</FONT></SPAN></LI></UL><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>We needed to copy the data to an isolated PM in order to make sure no other thread has access to the data we're saving. Otherwise there would be memory concurrency problems that you definitely never want to have to debug. Since only the BackgroundSaver has access to its private PM, we're safe.</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>What if the background&nbsp;save fails? </FONT></SPAN><SPAN =062041823-13092007><FONT face=Arial size=2>You'll have to capture the exception information in background and report it in the call back. Now, when the method returns reporting the problem, you have to figure out what to do. This is not that much different from how you handle a synchronous&nbsp;save failure. But it is a little different because the user thought he moved on ... and your program is suddenly going to be saying "hey, excuse me but, you know that save from a few seconds ago? Well ... there's been a problem."</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>That, in my mind, is how it gets tricky.</FONT></SPAN></DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV><DIV><SPAN =062041823-13092007><FONT face=Arial size=2>Hope this helps</FONT></SPAN></DIV>]]>
   </description>
   <pubDate>Thu, 13 Sep 2007 20:56:30 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=429&amp;PID=1180#1180</guid>
  </item> 
  <item>
   <title>Asynch Save : When should I consider Asynch...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=429&amp;PID=1179#1179</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=20" rel="nofollow">Customer</a><br /><strong>Subject:</strong> 429<br /><strong>Posted:</strong> 13-Sep-2007 at 8:54pm<br /><br />When should I consider Asynch Save?]]>
   </description>
   <pubDate>Thu, 13 Sep 2007 20:54:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=429&amp;PID=1179#1179</guid>
  </item> 
 </channel>
</rss>