<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lars Wilhelmsen &#187; Persistence Provider</title>
	<atom:link href="http://www.larswilhelmsen.com/category/persistence-provider/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.larswilhelmsen.com</link>
	<description>Microsoft Connected Systems MVP</description>
	<lastBuildDate>Tue, 22 Jun 2010 08:24:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Codename &#8220;Velocity&#8221; WF/WCF Persistence Provider</title>
		<link>http://www.larswilhelmsen.com/2008/12/11/codename-velocity-wfwcf-persistence-provider/</link>
		<comments>http://www.larswilhelmsen.com/2008/12/11/codename-velocity-wfwcf-persistence-provider/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 20:24:24 +0000</pubDate>
		<dc:creator>larsw</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Persistence Provider]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[WF]]></category>

		<guid isPermaLink="false">http://larsw.wordpress.com/2008/12/11/codename-velocity-wfwcf-persistence-provider/</guid>
		<description><![CDATA[So, it’s been a bit quiet here lately. The natural cause of it is (in no particular order): A lot of work Spending quality time with my son Hacking on different kinds of technology bits (mainly pieces released at the PDC 2008) I’ve also tried to get a clear picture of my “blind spots” when [...]]]></description>
			<content:encoded><![CDATA[<p>So, it’s been a bit quiet here lately. The natural cause of it is (in no particular order):</p>
<ul>
<li>A lot of work</li>
<li>Spending quality time with my son</li>
<li>Hacking on different kinds of technology bits (mainly pieces released at the PDC 2008)</li>
</ul>
<p>I’ve also tried to get a clear picture of my “blind spots” when it comes to WCF. Even though I feel quite competent, there are still tons of stuff that I don’t touch daily so I still have to “rehearse”.</p>
<p>Since I have “Get to know Workflow Foundation – for real” on my TODO list I spent some time playing with durable services.</p>
<p>The persistence provider mechanism that is located in <strong>System.WorkflowServices</strong> is not exclusive to to Workflows / Workflow services. It can also be used with “vanilla” WCF Services.</p>
<p>The idea is that the framework can persist the service instance after you have invoked a method and when a future method invocation comes down the wire, it can pull it from the persistence store – revive it and pass the call to the “same” instance. A perfect fit for the scenario of long running services.</p>
<p>So how do you enable durable services? It is quite easy. First, you decorate your service implementation with <strong>[DurableService]</strong> and one of the mechanisms that specifies that the type is <em>serializable</em> (I chose <strong>[Serializable]</strong> for the sake of simplicity).</p>
<p><img style="display:inline;" title="image" src="http://larsw.files.wordpress.com/2008/12/image.png" alt="image" width="352" height="543" /></p>
<p>In this code snippet we also see that there is another attribute that can be used to tell the persistence mechanism that a call to an operation creates the instance or tears it down; <a href="http://msdn.microsoft.com/en-us/system.servicemodel.description.durableoperationattribute.aspx" target="_blank">[DurableOperation]</a>.</p>
<p>The next thing you have to do is to wire up a persistence provider using either configuration or programmatically.</p>
<p>Out of the box there exists only one Persistence Provider; One suited for persisting the service instances to SQL Server – <em>System.ServiceModel.Persistence.SqlPersistenceProviderFactory.</em> You will have to set up a SQL Server Database instance with the schema located in <em>C:\Windows\Microsoft.NET\Framework\v3.5\SQL\EN</em>.</p>
<p>But that was a digression – now back to my custom “Velocity” Persistence Provider. If you don’t know what Codename “Velocity” is, I suggest that you head over <a href="http://blogs.msdn.com/velocity/" target="_blank">here</a> and read more about it. The short description:</p>
<p>It is Microsoft’s attempt to create an in-memory, high-performance, distributed caching supporting different scenarios that can suite many needs in both a web farm or other places where caching is needed. The current version that is publicly available is CTP2. We should expect a new CTP in March (around the time of MIX’09) and the RTW/RTM in the mid of 2009.</p>
<p>To implement a custom persistence provider, you will have to create two classes; the persistence provider implementation and its factory. It is the fully qualified type name of the factory that is specified when you set up the configuration.</p>
<p>The following configuration snippet shows how a custom service behavior is set up. You will have to set the <em>behaviorConfiguration</em> attribute on the service element to <strong>“defaultServiceBehavior”</strong> in this case.</p>
<p><img style="display:inline;" title="image" src="http://larsw.files.wordpress.com/2008/12/image1.png" alt="image" width="497" height="161" /></p>
<p>The code for the provider is available <a href="http://larsw-public.s3.amazonaws.com/LarsW.VelocityPersistenceProvider-1.0.0.zip" target="_blank">here</a> (Licensed under the <em>Apache License 2.0</em>).</p>
<p>Cheers <img src='http://www.larswilhelmsen.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <br />
<a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2flarswilhelmsen.com%2f2008%2f12%2f11%2fcodename-velocity-wfwcf-persistence-provider%2f"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2flarswilhelmsen.com%2f2008%2f12%2f11%2fcodename-velocity-wfwcf-persistence-provider%2f" border="0" alt="kick it on DotNetKicks.com" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.larswilhelmsen.com/2008/12/11/codename-velocity-wfwcf-persistence-provider/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
