<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">

<channel>
	<title>Philip Richardson</title>
	
	<link>http://blog.philiprichardson.org</link>
	<description>Business Software in the Cloud</description>
	<lastBuildDate>Tue, 23 Jun 2009 04:21:01 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/23553a1f56860f5db931469bb39fd56f?s=96&amp;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Philip Richardson</title>
		<link>http://blog.philiprichardson.org</link>
	</image>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/PhilipRichardson" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Sketch Flow</title>
		<link>http://blog.philiprichardson.org/2009/06/23/sketch-flow/</link>
		<comments>http://blog.philiprichardson.org/2009/06/23/sketch-flow/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 04:21:01 +0000</pubDate>
		<dc:creator>philiprichardson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.philiprichardson.org/?p=649</guid>
		<description><![CDATA[I&#8217;m writing a couple of UI specs for work and I decided to give &#8216;Sketch Flow&#8217; a run. Sketch Flow is an component of Expression Blend which gives it early stage design tools. You can lay out the flow of your interface and use &#8216;wiggly styles&#8217; to draw controls. The advantage of these imprecise controls [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.philiprichardson.org&blog=6378910&post=649&subd=philiprichardson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;m writing a couple of UI specs for work and I decided to give &#8216;Sketch Flow&#8217; a run. Sketch Flow is an component of Expression Blend which gives it early stage design tools. You can lay out the flow of your interface and use &#8216;wiggly styles&#8217; to draw controls. The advantage of these imprecise controls is that you (the designer) doesn&#8217;t get caught up with perfection and that your audience (peers + stakeholders) can clearly see that the UI is still a work in progress. This level of implicit communication is never to be underestimated during featue design. This video from MIX gives a good overview of the product: <a href="http://videos.visitmix.com/MIX09/C01F">http://videos.visitmix.com/MIX09/C01F</a>.</p>
<p>I&#8217;m not sure I&#8217;d ever convert my Sketch Flow projects to a full Silverlight or WPF project (as the product intends) &#8211; but there is huge value in simply having a more formal way of documenting UI design.</p>
<p>BTW: Sorry for being slow on the blogging lately. I&#8217;ve been working on semi-secret and rather internally focused infrastructure things. Thus I&#8217;ve had not too much to blog about. I&#8217;ve been a lot of Silverlight 3.0 in my &#8217;spare&#8217; time and I&#8217;m enjoying where the product is going from a Line of Business apps perspective.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiprichardson.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiprichardson.wordpress.com/649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/philiprichardson.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/philiprichardson.wordpress.com/649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/philiprichardson.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/philiprichardson.wordpress.com/649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/philiprichardson.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/philiprichardson.wordpress.com/649/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/philiprichardson.wordpress.com/649/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/philiprichardson.wordpress.com/649/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.philiprichardson.org&blog=6378910&post=649&subd=philiprichardson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.philiprichardson.org/2009/06/23/sketch-flow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">philiprichardson</media:title>
		</media:content>
	</item>
		<item>
		<title>Utilizing the Service Bus in Windows Azure</title>
		<link>http://blog.philiprichardson.org/2009/05/23/utilizing-the-service-bus-in-windows-azure/</link>
		<comments>http://blog.philiprichardson.org/2009/05/23/utilizing-the-service-bus-in-windows-azure/#comments</comments>
		<pubDate>Sat, 23 May 2009 05:00:09 +0000</pubDate>
		<dc:creator>philiprichardson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.philiprichardson.org/2009/05/23/utilizing-the-service-bus-in-windows-azure/</guid>
		<description><![CDATA[In this basic tutorial we&#8217;ll focus on two basic scenarios:


Service Bus Client in a Windows Azure Web or Worker Role

Service Bus Listener in a Windows Azure Worker Role


Pre-Requisites

You&#8217;ll need to do some basic setup before you start coding. This tutorial assumes you have accounts for Windows Azure and .NET Services, have completed &#8216;Hello World&#8217; style [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.philiprichardson.org&blog=6378910&post=645&subd=philiprichardson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In this basic tutorial we&#8217;ll focus on two basic scenarios:
</p>
<ol>
<li>Service Bus Client in a Windows Azure Web or Worker Role
</li>
<li>Service Bus Listener in a Windows Azure Worker Role
</li>
</ol>
<h2>Pre-Requisites<br />
</h2>
<p>You&#8217;ll need to do some basic setup before you start coding. This tutorial assumes you have accounts for Windows Azure and .NET Services, have completed &#8216;Hello World&#8217; style tutorials and have downloaded and installed all the relevant SDKs.
</p>
<h2>Full Trust Code<br />
</h2>
<p>.NET Services required Full Trust to run. You&#8217;ll need to set the &#8216;enableNativeCodeExecution&#8217; attribute to be true in the ServiceDefinition.csdef file of your Windows Azure Project.
</p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">&lt;?</span><span style="color:#a31515;">xml</span><span style="color:blue;"><br />
			</span><span style="color:red;">version</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">1.0</span>&#8220;<span style="color:blue;"><br />
			</span><span style="color:red;">encoding</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">utf-8</span>&#8220;<span style="color:blue;">?&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">ServiceDefinition</span><span style="color:blue;"><br />
			</span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">AzureSample</span>&#8220;<span style="color:blue;"><br />
			</span><span style="color:red;">xmlns</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition</span>&#8220;<span style="color:blue;">&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">  &lt;</span><span style="color:#a31515;">WebRole</span><span style="color:blue;"><br />
			</span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">WebRole</span>&#8220;<span style="color:blue;"><br />
			</span><span style="color:red;">enableNativeCodeExecution</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8220;<span style="color:blue;">&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">    &lt;</span><span style="color:#a31515;">InputEndpoints</span><span style="color:blue;">&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">      &lt;!&#8211;</span><span style="color:green;"> Must use port 80 for http and port 443 for https when running in the cloud </span><span style="color:blue;">&#8211;&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">      &lt;</span><span style="color:#a31515;">InputEndpoint</span><span style="color:blue;"><br />
			</span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">HttpIn</span>&#8220;<span style="color:blue;"><br />
			</span><span style="color:red;">protocol</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">http</span>&#8220;<span style="color:blue;"><br />
			</span><span style="color:red;">port</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">80</span>&#8220;<span style="color:blue;"> /&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">    &lt;/</span><span style="color:#a31515;">InputEndpoints</span><span style="color:blue;">&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">  &lt;/</span><span style="color:#a31515;">WebRole</span><span style="color:blue;">&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">  &lt;</span><span style="color:#a31515;">WorkerRole</span><span style="color:blue;"><br />
			</span><span style="color:red;">name</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">WorkerRole</span>&#8220;<span style="color:blue;"><br />
			</span><span style="color:red;">enableNativeCodeExecution</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">true</span>&#8220;<span style="color:blue;">&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">  &lt;/</span><span style="color:#a31515;">WorkerRole</span><span style="color:blue;">&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">ServiceDefinition</span><span style="color:blue;">&gt;<br />
</span></span></p>
<h2>Service Bus Client<span style="color:#4f81bd;"><br />
		</span></h2>
<p>In this example we&#8217;ll create a normal Service Bus Listener and run that on-premise. This Listener will receive messages from the Service Bus and display them in a console window. We&#8217;ll also create a small client library which can be run from a Windows Azure Web or Worker role.
</p>
<p>Our scenario is a simple one: Imagine you wanted to get real time logging information from your Windows Azure application. Instead of writing to the Windows Azure log API, manually transferring the logs to a blob and then download the data – we&#8217;ll write out directly to the Service Bus.
</p>
<h3>The Listener<br />
</h3>
<p>This is a super simple Console Application consisting of 3 files: Program.cs, ILogContract and ILogService. This Listener differs slightly from a regular Service Bus application. It packages Microsoft.ServiceBus.dll directly in its bin (ie. It doesn&#8217;t care if you have the SDK or Redist installed) and it sets all the WCF/SB config in code. Becareful: By packaging Microsoft.ServiceBus.dll yourself you are now responsible for servicing (ie. Updating) this dll on any clients you distribute it to. You&#8217;ll also note that the User Name, Password and Service Bus URI have been stored in AppSettings.
</p>
<h4>ILogContract.cs<br />
</h4>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.ServiceModel;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Collections.Generic;<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">namespace</span> AzureSample<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">{<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    [<span style="color:#2b91af;">ServiceContract</span>(Name = <span style="color:#a31515;">"ILogContract"</span>, Namespace = <span style="color:#a31515;">"http://tempuri.org/"</span>)]<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">interface</span><br />
			<span style="color:#2b91af;">ILogContract<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        [<span style="color:#2b91af;">OperationContract</span>]<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">void</span> WriteToLog(<span style="color:#2b91af;">DateTime</span> eventDt, <span style="color:blue;">string</span> source, <span style="color:blue;">string</span> text);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    }<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">interface</span><br />
			<span style="color:#2b91af;">ILogChannel</span> : <span style="color:#2b91af;">ILogContract</span>, <span style="color:#2b91af;">IClientChannel</span> { }<br />
</span></p>
<h4>LogService.cs<br />
</h4>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.ServiceModel;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Text;<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">namespace</span> AzureSample<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">{<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    [<span style="color:#2b91af;">ServiceBehavior</span>(Name = <span style="color:#a31515;">"LogService"</span>, Namespace = <span style="color:#a31515;">"http://tempuri.org/"</span>)]<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">class</span><br />
			<span style="color:#2b91af;">LogService</span>: <span style="color:#2b91af;">ILogContract<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">void</span> WriteToLog(<span style="color:#2b91af;">DateTime</span> eventDt, <span style="color:blue;">string</span> source, <span style="color:blue;">string</span> text)<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:blue;">string</span>.Format(<span style="color:#a31515;">&#8220;From {0} at {1}: {2}&#8221;</span>, eventDt.ToString(), source, text));<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">}<br />
</span></p>
<h4>Program.cs<br />
</h4>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Configuration;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.ServiceModel;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.ServiceModel.Description;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> Microsoft.ServiceBus;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> Microsoft.ServiceBus.Description;<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">namespace</span> AzureSample<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">{<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">class</span><br />
			<span style="color:#2b91af;">Program<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">static</span><br />
			<span style="color:blue;">void</span> Main(<span style="color:blue;">string</span>[] args)<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">string</span> endPoint = <span style="color:#2b91af;">ConfigurationSettings</span>.AppSettings[<span style="color:#a31515;">"EndPoint"</span>];<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">string</span> userName = <span style="color:#2b91af;">ConfigurationSettings</span>.AppSettings[<span style="color:#a31515;">"UserName"</span>];<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">string</span> password = <span style="color:#2b91af;">ConfigurationSettings</span>.AppSettings[<span style="color:#a31515;">"Password"</span>];<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">Uri</span> uri = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">Uri</span>(endPoint);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">TransportClientEndpointBehavior</span> userNamePasswordServiceBusCredential = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">TransportClientEndpointBehavior</span>();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            userNamePasswordServiceBusCredential.CredentialType = <span style="color:#2b91af;">TransportClientCredentialType</span>.UserNamePassword;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            userNamePasswordServiceBusCredential.Credentials.UserName.UserName = userName;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            userNamePasswordServiceBusCredential.Credentials.UserName.Password = password;<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">ServiceHost</span> host = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">ServiceHost</span>(<span style="color:blue;">typeof</span>(<span style="color:#2b91af;">LogService</span>), uri);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">ContractDescription</span> contractDescription = <span style="color:#2b91af;">ContractDescription</span>.GetContract(<span style="color:blue;">typeof</span>(<span style="color:#2b91af;">ILogContract</span>), <span style="color:blue;">typeof</span>(<span style="color:#2b91af;">LogService</span>));<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">ServiceEndpoint</span> serviceEndPoint = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">ServiceEndpoint</span>(contractDescription);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            serviceEndPoint.Address = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">EndpointAddress</span>(uri);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            serviceEndPoint.Binding = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">NetTcpRelayBinding</span>();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            serviceEndPoint.Behaviors.Add(userNamePasswordServiceBusCredential);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            host.Description.Endpoints.Add(serviceEndPoint);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;">            host.Open();<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#2b91af;">String</span>.Format(<span style="color:#a31515;">&#8220;Listening at: {0}&#8221;</span>, endPoint));<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">&#8220;Press [Enter] to exit&#8221;</span>);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">Console</span>.ReadLine();<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;">            host.Close();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">}<br />
</span></p>
<h4>App.config<br />
</h4>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">&lt;?</span><span style="color:#a31515;">xml</span><span style="color:blue;"><br />
			</span><span style="color:red;">version</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">1.0</span>&#8220;<span style="color:blue;"><br />
			</span><span style="color:red;">encoding</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">utf-8</span>&#8220;<span style="color:blue;"> ?&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">&lt;</span><span style="color:#a31515;">configuration</span><span style="color:blue;">&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">  &lt;</span><span style="color:#a31515;">appSettings</span><span style="color:blue;">&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">    &lt;</span><span style="color:#a31515;">add</span><span style="color:blue;"><br />
			</span><span style="color:red;">key</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">UserName</span>&#8220;<span style="color:blue;"><br />
			</span><span style="color:red;">value</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">MY SOLUTION NAME</span>&#8220;<span style="color:blue;">/&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">    &lt;</span><span style="color:#a31515;">add</span><span style="color:blue;"><br />
			</span><span style="color:red;">key</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">Password</span>&#8220;<span style="color:blue;"><br />
			</span><span style="color:red;">value</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">MY PASSWORD</span>&#8220;<span style="color:blue;">/&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">    &lt;</span><span style="color:#a31515;">add</span><span style="color:blue;"><br />
			</span><span style="color:red;">key</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">EndPoint</span>&#8220;<span style="color:blue;"><br />
			</span><span style="color:red;">value</span><span style="color:blue;">=</span>&#8220;<span style="color:blue;">sb://mysolutionname.servicebus.windows.net/sample/log/</span>&#8220;<span style="color:blue;">/&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">  &lt;/</span><span style="color:#a31515;">appSettings</span><span style="color:blue;">&gt;<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">&lt;/</span><span style="color:#a31515;">configuration</span><span style="color:blue;">&gt;</span></span>
	</p>
<p>
 </p>
<h3>The Client<br />
</h3>
<p>Now we need to start sending some messages to the client. We&#8217;ll create a class which we can easily re-use in a Web or Worker project. In fact you could run this class on pretty much any remote hosting environment. You&#8217;ll also need to store some credentials and the URI in the web.config or app.config for a web or worker role respectively.
</p>
<h4>ServiceBusLoggerClass.cs<br />
</h4>
<p>This class can be added as an external DLL or directly to the Worker/Web Role. Remember it needs Microsoft.ServiceBus.dll to work.
</p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.ServiceModel;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.ServiceModel.Activation;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> Microsoft.ServiceBus;<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">namespace</span> AzureSample<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">{<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">class</span><br />
			<span style="color:#2b91af;">ServiceBusLogger<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:#2b91af;">ILogChannel</span> Channel {<span style="color:blue;">get</span>;<span style="color:blue;">set</span>;}<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span> ServiceBusLogger(<span style="color:blue;">string</span> endPoint, <span style="color:blue;">string</span> userName, <span style="color:blue;">string</span> password)<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">Uri</span> uri = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">Uri</span>(endPoint);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">TransportClientEndpointBehavior</span> userNamePasswordServiceBusCredential = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">TransportClientEndpointBehavior</span>();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            userNamePasswordServiceBusCredential.CredentialType = <span style="color:#2b91af;">TransportClientCredentialType</span>.UserNamePassword;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            userNamePasswordServiceBusCredential.Credentials.UserName.UserName = userName;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            userNamePasswordServiceBusCredential.Credentials.UserName.Password = password;<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">ChannelFactory</span>&lt;<span style="color:#2b91af;">ILogChannel</span>&gt; channelFactory = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">ChannelFactory</span>&lt;<span style="color:#2b91af;">ILogChannel</span>&gt;();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            channelFactory.Endpoint.Address = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">EndpointAddress</span>(uri);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            channelFactory.Endpoint.Binding = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">NetTcpRelayBinding</span>();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            channelFactory.Endpoint.Contract.ContractType = <span style="color:blue;">typeof</span>(<span style="color:#2b91af;">ILogChannel</span>);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;">            channelFactory.Endpoint.Behaviors.Add(userNamePasswordServiceBusCredential);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">this</span>.Channel = channelFactory.CreateChannel();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">}<br />
</span></p>
<h4>Calling the Logger – eg. A Worker Role<br />
</h4>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Collections.Generic;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Threading;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Linq;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Text;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> Microsoft.ServiceHosting.ServiceRuntime;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Configuration;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> AzureSample;<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">namespace</span> AzureSample_WorkerRole<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">{<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">class</span><br />
			<span style="color:#2b91af;">WorkerRole</span> : <span style="color:#2b91af;">RoleEntryPoint<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">override</span><br />
			<span style="color:blue;">void</span> Start()<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">string</span> endPoint = <span style="color:#2b91af;">ConfigurationSettings</span>.AppSettings[<span style="color:#a31515;">"EndPoint"</span>];<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">string</span> userName = <span style="color:#2b91af;">ConfigurationSettings</span>.AppSettings[<span style="color:#a31515;">"UserName"</span>];<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">string</span> password = <span style="color:#2b91af;">ConfigurationSettings</span>.AppSettings[<span style="color:#a31515;">"Password"</span>];<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">ServiceBusLogger</span> logger = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">ServiceBusLogger</span>(endPoint, userName, password);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;">            logger.Channel.WriteToLog(<span style="color:#2b91af;">DateTime</span>.UtcNow, <span style="color:#a31515;">&#8220;Worker Role&#8221;</span>, <span style="color:#a31515;">&#8220;Role Started&#8221;</span>);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">while</span> (<span style="color:blue;">true</span>)<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">Thread</span>.Sleep(1000);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">                logger.Channel.WriteToLog(<span style="color:#2b91af;">DateTime</span>.UtcNow, <span style="color:#a31515;">&#8220;Worker Role&#8221;</span>, <span style="color:#a31515;">&#8220;Working&#8230;&#8221;</span>);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">override</span><br />
			<span style="color:#2b91af;">RoleStatus</span> GetHealthStatus()<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:green;">// This is a sample worker implementation. Replace with your logic.<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">return</span><br />
			<span style="color:#2b91af;">RoleStatus</span>.Healthy;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">}<br />
</span></p>
<h4>SampleOutput<br />
</h4>
<p>Here is some sample output from the console:
</p>
<p style="margin-left:36pt;">Listening at: sb://*******.servicebus.windows.net/sample/log/
</p>
<p style="margin-left:36pt;">Press [Enter] to exit
</p>
<p style="margin-left:36pt;">From 5/23/2009 4:30:44 AM at Worker Role: Role Started
</p>
<p style="margin-left:36pt;">From 5/23/2009 4:30:51 AM at Worker Role: Working&#8230;
</p>
<p style="margin-left:36pt;">From 5/23/2009 4:30:52 AM at Worker Role: Working&#8230;
</p>
<p style="margin-left:36pt;">From 5/23/2009 4:30:53 AM at Worker Role: Working&#8230;
</p>
<p style="margin-left:36pt;">From 5/23/2009 4:30:54 AM at Worker Role: Working&#8230;
</p>
<p style="margin-left:36pt;">From 5/23/2009 4:30:55 AM at Worker Role: Working&#8230;
</p>
<h2>Hosting a Listener in Worker Role<br />
</h2>
<p>It&#8217;s relatively straight forward to host a Service Bus Listener in a Worker Role. Here is a version of the Calculator Service running inside Worker Role.
</p>
<h4>CalculatorService.c s<br />
</h4>
<p>Here is the CalculatorService.cs from the .NET Services SDK to refresh your memory. I&#8217;ve added this class directly to my worker role. I&#8217;ve remove the Access Control helpers from this sample for simplicity&#8217;s sake.
</p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">namespace</span> Microsoft.ServiceBus.Samples<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">{<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">using</span> System;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">using</span> System.Runtime.Serialization;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">using</span> System.ServiceModel;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">using</span> System.ServiceModel.Channels;<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:green;">// Define a service contract.<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    [<span style="color:#2b91af;">ServiceContract</span>(Name = <span style="color:#a31515;">"Calculator"</span>, Namespace = <span style="color:#a31515;">"http://Microsoft.ServiceModel.Samples"</span>)]<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">interface</span><br />
			<span style="color:#2b91af;">ICalculator<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        [<span style="color:#2b91af;">OperationContract</span>(Action = <span style="color:#a31515;">"Add"</span>, ReplyAction = <span style="color:#a31515;">"AddResponse"</span>)]<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">double</span> Add(<span style="color:blue;">double</span> n1, <span style="color:blue;">double</span> n2);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;">        [<span style="color:#2b91af;">OperationContract</span>(Action = <span style="color:#a31515;">"Subtract"</span>, ReplyAction = <span style="color:#a31515;">"SubtractResponse"</span>)]<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">double</span> Subtract(<span style="color:blue;">double</span> n1, <span style="color:blue;">double</span> n2);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;">        [<span style="color:#2b91af;">OperationContract</span>(Action = <span style="color:#a31515;">"Multiply"</span>, ReplyAction = <span style="color:#a31515;">"MultiplyResponse"</span>)]<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">double</span> Multiply(<span style="color:blue;">double</span> n1, <span style="color:blue;">double</span> n2);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;">        [<span style="color:#2b91af;">OperationContract</span>(Action = <span style="color:#a31515;">"Divide"</span>, ReplyAction = <span style="color:#a31515;">"DivideResponse"</span>)]<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">double</span> Divide(<span style="color:blue;">double</span> n1, <span style="color:blue;">double</span> n2);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    }<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:green;">// Service class which implements the service contract.<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">class</span><br />
			<span style="color:#2b91af;">CalculatorService</span> : <span style="color:#2b91af;">ICalculator<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">double</span> Add(<span style="color:blue;">double</span> n1, <span style="color:blue;">double</span> n2)<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">return</span> n1 + n2;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">double</span> Subtract(<span style="color:blue;">double</span> n1, <span style="color:blue;">double</span> n2)<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">return</span> n1 &#8211; n2;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">double</span> Multiply(<span style="color:blue;">double</span> n1, <span style="color:blue;">double</span> n2)<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">return</span> n1 * n2;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">double</span> Divide(<span style="color:blue;">double</span> n1, <span style="color:blue;">double</span> n2)<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">return</span> n1 / n2;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">}<br />
</span></p>
<h4>WorkerRole.cs<br />
</h4>
<p>Here is my WorkerRole.cs. I&#8217;ve configured my Service Bus listener with code only (with App Settings for the URI and credentials only). I&#8217;ve also physically included the Microsoft.ServiceBus.dll in my project. You&#8217;ll also note I&#8217;ve over-ridden the Stop() method of RoleEntryPoint to close the Host when the Worker Role shuts down.
</p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Collections.Generic;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Threading;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Linq;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Text;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> Microsoft.ServiceHosting.ServiceRuntime;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.Configuration;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> Microsoft.ServiceBus.Samples;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.ServiceModel;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> System.ServiceModel.Description;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> Microsoft.ServiceBus;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">using</span> Microsoft.ServiceBus.Description;<br />
</span></p>
<p>
 </p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><span style="color:blue;">namespace</span> AzureSample_WorkerRole<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">{<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">class</span><br />
			<span style="color:#2b91af;">WorkerRole</span> : <span style="color:#2b91af;">RoleEntryPoint<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">private</span><br />
			<span style="color:#2b91af;">ServiceHost</span> host;<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">override</span><br />
			<span style="color:blue;">void</span> Start()<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">string</span> endPoint = <span style="color:#2b91af;">ConfigurationSettings</span>.AppSettings[<span style="color:#a31515;">"EndPoint"</span>];<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">string</span> userName = <span style="color:#2b91af;">ConfigurationSettings</span>.AppSettings[<span style="color:#a31515;">"UserName"</span>];<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">string</span> password = <span style="color:#2b91af;">ConfigurationSettings</span>.AppSettings[<span style="color:#a31515;">"Password"</span>];<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">Uri</span> uri = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">Uri</span>(endPoint);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">TransportClientEndpointBehavior</span> userNamePasswordServiceBusCredential = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">TransportClientEndpointBehavior</span>();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            userNamePasswordServiceBusCredential.CredentialType = <span style="color:#2b91af;">TransportClientCredentialType</span>.UserNamePassword;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            userNamePasswordServiceBusCredential.Credentials.UserName.UserName = userName;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            userNamePasswordServiceBusCredential.Credentials.UserName.Password = password;<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;">            host = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">ServiceHost</span>(<span style="color:blue;">typeof</span>(<span style="color:#2b91af;">CalculatorService</span>), uri);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">ContractDescription</span> contractDescription = <span style="color:#2b91af;">ContractDescription</span>.GetContract(<span style="color:blue;">typeof</span>(<span style="color:#2b91af;">ICalculator</span>), <span style="color:blue;">typeof</span>(<span style="color:#2b91af;">CalculatorService</span>));<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:#2b91af;">ServiceEndpoint</span> serviceEndPoint = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">ServiceEndpoint</span>(contractDescription);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            serviceEndPoint.Address = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">EndpointAddress</span>(uri);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            serviceEndPoint.Binding = <span style="color:blue;">new</span><br />
			<span style="color:#2b91af;">NetTcpRelayBinding</span>();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            serviceEndPoint.Behaviors.Add(userNamePasswordServiceBusCredential);<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            host.Description.Endpoints.Add(serviceEndPoint);<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;">            host.Open();<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">while</span> (<span style="color:blue;">true</span>)<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:green;">//Loop<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">override</span><br />
			<span style="color:blue;">void</span>  Stop()<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">            host.Close();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">             <span style="color:blue;">base</span>.Stop();<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p>
 </p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">public</span><br />
			<span style="color:blue;">override</span><br />
			<span style="color:#2b91af;">RoleStatus</span> GetHealthStatus()<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        {<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:green;">// This is a sample worker implementation. Replace with your logic.<br />
</span></span></p>
<p><span style="font-family:Courier New;font-size:10pt;"><br />
			<span style="color:blue;">return</span><br />
			<span style="color:#2b91af;">RoleStatus</span>.Healthy;<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">        }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">    }<br />
</span></p>
<p><span style="font-family:Courier New;font-size:10pt;">}<br />
</span></p>
<h2>Advanced Scenarios<br />
</h2>
<p>In these examples we used a basic NetTcpRelay Binding. You could easily imagine expanding these very simple scenarios to take advantage of other bindings, queues and routes provided by the Service Bus.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiprichardson.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiprichardson.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/philiprichardson.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/philiprichardson.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/philiprichardson.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/philiprichardson.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/philiprichardson.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/philiprichardson.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/philiprichardson.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/philiprichardson.wordpress.com/645/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.philiprichardson.org&blog=6378910&post=645&subd=philiprichardson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.philiprichardson.org/2009/05/23/utilizing-the-service-bus-in-windows-azure/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">philiprichardson</media:title>
		</media:content>
	</item>
		<item>
		<title>Azure Developer Challenge</title>
		<link>http://blog.philiprichardson.org/2009/05/05/azure-developer-challenge/</link>
		<comments>http://blog.philiprichardson.org/2009/05/05/azure-developer-challenge/#comments</comments>
		<pubDate>Tue, 05 May 2009 16:08:03 +0000</pubDate>
		<dc:creator>philiprichardson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.philiprichardson.org/?p=642</guid>
		<description><![CDATA[Our Marketing Folks are running a dev contest. More info here and here. Hopefully we&#8217;ll see some innovative use of .NET Services in the contest.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.philiprichardson.org&blog=6378910&post=642&subd=philiprichardson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Our Marketing Folks are running a dev contest. More <a href="http://www.newcloudapp.com/">info</a> here and <a href="http://blogs.msdn.com/stevemar/">here</a>. Hopefully we&#8217;ll see some innovative use of .NET Services in the contest.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiprichardson.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiprichardson.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/philiprichardson.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/philiprichardson.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/philiprichardson.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/philiprichardson.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/philiprichardson.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/philiprichardson.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/philiprichardson.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/philiprichardson.wordpress.com/642/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.philiprichardson.org&blog=6378910&post=642&subd=philiprichardson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.philiprichardson.org/2009/05/05/azure-developer-challenge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">philiprichardson</media:title>
		</media:content>
	</item>
		<item>
		<title>Do some phones lack a Mute button?</title>
		<link>http://blog.philiprichardson.org/2009/04/30/do-some-phones-lack-a-mute-button/</link>
		<comments>http://blog.philiprichardson.org/2009/04/30/do-some-phones-lack-a-mute-button/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 15:30:42 +0000</pubDate>
		<dc:creator>philiprichardson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://philiprichardson.wordpress.com/2009/04/30/do-some-phones-lack-a-mute-button/</guid>
		<description><![CDATA[Do they still make phones without a mute button? The number of people who can’t hit mute during a large teleconference beggars belief. Is there some awkward psychological principle at play which causes people to not realize?
Perhaps they should teach teleconference etiquette in business school…
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.philiprichardson.org&blog=6378910&post=641&subd=philiprichardson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Do they still make phones without a mute button? The number of people who can’t hit mute during a large teleconference beggars belief. Is there some awkward psychological principle at play which causes people to not realize?</p>
<p>Perhaps they should teach teleconference etiquette in business school…</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiprichardson.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiprichardson.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/philiprichardson.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/philiprichardson.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/philiprichardson.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/philiprichardson.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/philiprichardson.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/philiprichardson.wordpress.com/641/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/philiprichardson.wordpress.com/641/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/philiprichardson.wordpress.com/641/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.philiprichardson.org&blog=6378910&post=641&subd=philiprichardson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.philiprichardson.org/2009/04/30/do-some-phones-lack-a-mute-button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">philiprichardson</media:title>
		</media:content>
	</item>
		<item>
		<title>Silverlight 3.0 for Line of Business</title>
		<link>http://blog.philiprichardson.org/2009/04/30/silverlight-30-for-line-of-business/</link>
		<comments>http://blog.philiprichardson.org/2009/04/30/silverlight-30-for-line-of-business/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 15:26:05 +0000</pubDate>
		<dc:creator>philiprichardson</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://philiprichardson.wordpress.com/2009/04/30/silverlight-30-for-line-of-business/</guid>
		<description><![CDATA[The dominant user interface technology for line of business applications today is the web. The intranet/internet delivered web app burst onto the scene a few years ago and left many ‘fat clients’ lying obsolete in it’s wake. The promise of easy deployment and ‘interface ubiquity’ was tantalising for CIOs and Sys Admins everywhere.
Recently there has [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.philiprichardson.org&blog=6378910&post=640&subd=philiprichardson&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The dominant user interface technology for line of business applications today is the web. The intranet/internet delivered web app burst onto the scene a few years ago and left many ‘fat clients’ lying obsolete in it’s wake. The promise of easy deployment and ‘interface ubiquity’ was tantalising for CIOs and Sys Admins everywhere.</p>
<p>Recently there has been rumblings about performance and usability of these web based apps. The use of the AJAX technique has helped – bringing ‘fat client-esque’ performance to browser based applications.</p>
<p>Flash and Silverlight are now at a point where they are truly viable options for LOB systems. Previously both technologies had a strong focus on consumer/media scenarios. I believe that these Rich Internet Application (RIA) technologies are a good fit for LOB. The promise of browser based deployment along with the power of the client is a nice fit. The promise of easier dev/debug/test is also attractive (ie. debugging AJAX is troublesome at best).</p>
<p>While playing around with <a href="http://silverlight.net/getstarted/silverlight3/default.aspx">Silverlight 3.0</a> you can certainly see the LOB focused investments. The <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=76bb3a07-3846-4564-b0c3-27972bcaabce">.NET RIA Services</a> also provides middle tier technologies which eases some middle tier architectural head aches.</p>
<p>Give it a try… you won’t be disappointed.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiprichardson.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiprichardson.wordpress.com/640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/philiprichardson.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/philiprichardson.wordpress.com/640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/philiprichardson.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/philiprichardson.wordpress.com/640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/philiprichardson.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/philiprichardson.wordpress.com/640/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/philiprichardson.wordpress.com/640/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/philiprichardson.wordpress.com/640/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.philiprichardson.org&blog=6378910&post=640&subd=philiprichardson&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.philiprichardson.org/2009/04/30/silverlight-30-for-line-of-business/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">philiprichardson</media:title>
		</media:content>
	</item>
	</channel>
</rss>
