<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Richard Seroter&#039;s Architecture Musings</title>
	<atom:link href="http://seroter.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://seroter.wordpress.com</link>
	<description>Blog Featuring Code, Thoughts, and Experiences with Enterprise Solutions</description>
	<lastBuildDate>Tue, 24 Jan 2012 17:05:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='seroter.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Richard Seroter&#039;s Architecture Musings</title>
		<link>http://seroter.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://seroter.wordpress.com/osd.xml" title="Richard Seroter&#039;s Architecture Musings" />
	<atom:link rel='hub' href='http://seroter.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Building an OData Web Service on Iron Foundry</title>
		<link>http://seroter.wordpress.com/2012/01/24/building-an-odata-web-service-on-iron-foundry/</link>
		<comments>http://seroter.wordpress.com/2012/01/24/building-an-odata-web-service-on-iron-foundry/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 15:00:57 +0000</pubDate>
		<dc:creator>Richard Seroter</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Cloud Foundry]]></category>

		<guid isPermaLink="false">https://seroter.wordpress.com/?p=1955</guid>
		<description><![CDATA[In my previous posts on Iron Foundry, I did a quick walkthrough of the tooling, and then showed how to use external libraries to communicate from the cloud to an on-premises service. One thing that I hadn’t done yet was use the various application services that are available to Iron Foundry application developers. In this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1955&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my previous posts on <a href="http://www.ironfoundry.org/" target="_blank">Iron Foundry</a>, I did a quick <a href="http://seroter.wordpress.com/2011/12/13/first-look-deploying-net-web-apps-to-cloud-foundry-via-iron-foundry/" target="_blank">walkthrough of the tooling</a>, and then showed how to use external libraries to <a href="http://seroter.wordpress.com/2011/12/27/sending-messages-to-azure-appfabric-service-bus-topics-from-iron-foundry/" target="_blank">communicate from the cloud to an on-premises service</a>. One thing that I hadn’t done yet was use the various application services that are available to Iron Foundry application developers. In this post, I’ll show you how to provision a SQL Server database, create a set of tables, populate data, and expose that data via an <a href="http://www.odata.org/" target="_blank">OData web service</a>.</p>
<p>The first challenge we face is how to actually interact with our Iron Foundry SQL Server service. At this point, Iron Foundry (and Cloud Foundry) <strong>doesn’t support direct tunneling to the application services</strong>. That means that I can’t just point the SQL Server 2008 Management Studio to a cloud database and use the GUI to muck with database properties. SQL Azure supports this, and hopefully we’ll see this added to the Cloud Foundry stack in the near future.</p>
<p>But one man’s challenge is … well, another man’s challenge. But, it’s an entirely solvable one. I decided to use the Microsoft Entity Framework to model a data structure, generate the corresponding database script, and run that against the Iron Foundry environment. I can do all of this locally (with my own SQL Server) to test it before deploying to Iron Foundry. Let’s do that.</p>
<h3>Step 1: Generate the Data Model</h3>
<p>To start with, I created a new, empty ASP.NET web application. This will hold our Entity model, ASP.NET web page for creating the database tables and populating them with data, and the WCF Data Service that exposes our data sets. Then, I added a new ADO.NET Data Entity Model to the project.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry01.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry01" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry01_thumb.png?w=450&#038;h=423" alt="2012.1.16ironfoundry01" width="450" height="423" border="0" /></a></p>
<p>We’re not starting with an existing database here, so I chose the <strong>Empty Model</strong> option after creating this file. I then defined a simple set of entities representing Pets and Owners. The relationship indicates that an Owner may have multiple Pets.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry02.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry02" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry02_thumb.png?w=450&#038;h=461" alt="2012.1.16ironfoundry02" width="450" height="461" border="0" /></a></p>
<p>Now, to make my life easier, I generated the DDL script that would build a pair of tables based on this model. The script is produced by right-clicking the model and selecting the <strong>Generate Database from Model </strong>option.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry03.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry03" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry03_thumb.png?w=450&#038;h=309" alt="2012.1.16ironfoundry03" width="450" height="309" border="0" /></a></p>
<p>When walking through the <strong>Generate Database Wizard</strong>, I chose a database (“DemoDb”) on my own machine, and chose to save a connection entry in my web application’s configuration file. Note that the name used here (“PetModelContainer”) is the same name of the connection string the Entity Model expects to use when inflating the entities.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry04.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry04" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry04_thumb.png?w=298&#038;h=459" alt="2012.1.16ironfoundry04" width="298" height="459" border="0" /></a></p>
<p>When this wizard finished, we got a SQL script that can generate the tables and relationships.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry12.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry12" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry12_thumb.png?w=450&#038;h=315" alt="2012.1.16ironfoundry12" width="450" height="315" border="0" /></a></p>
<p><strong>Before proceeding,</strong> <strong>open up that file and comment out all the GO statements</strong>. Otherwise, the SqlCommand object will throw an error when trying to execute the script.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry05.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry05" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry05_thumb.png?w=295&#038;h=160" alt="2012.1.16ironfoundry05" width="295" height="160" border="0" /></a></p>
<h3>Step 2: Add WCF Data Service</h3>
<p>With the data model complete, I then added the WCF Data Service which exposes an OData endpoint for our entity model.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry06.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry06" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry06_thumb.png?w=450&#038;h=344" alt="2012.1.16ironfoundry06" width="450" height="344" border="0" /></a></p>
<p>These services are super-easy to configure. There are really only two things you HAVE to do in order to get this service working. First the topmost statement (class declaration) needs to be updated with the name of the data entity class. Secondly, I uncommented/added statements for the entity access rules. In the case below, I provided &#8220;Read” access to all entities in the model.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:a923d526-6235-4920-9a30-98b6ef26e69f" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; highlight: [8]; html-script: false; pad-line-numbers: true;">
public class PetService : DataService
    {
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
            // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
            // Examples:
            config.SetEntitySetAccessRule(&quot;*&quot;, EntitySetRights.AllRead);
            // config.SetServiceOperationAccessRule(&quot;MyServiceOperation&quot;, ServiceOperationRights.All);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
    }
</pre></p>
</div>
<p>Our service is now completed! That was easy.</p>
<h3>Step 3: Create a Web Form that Creates the Database and Loads Data</h3>
<p>I could not yet test this application since I haven’t physically constructed the underlying data structure. Since I cannot run the database script directly against the Iron Foundry database, I needed a host that can run this script. I chose an ASP.NET Web Form that could execute the script AND put some sample data in the tables.</p>
<p>Before creating the web page, I added an entry in my web.config file. Specifically, I added a new connection string entry that holds the details I need to connect to my LOCAL database.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:37f83c69-00ed-4de0-8ce1-5626da00bc76" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: xml; highlight: [3]; wrap-lines: false;">
&lt;connectionStrings&gt;
&lt;add name=&quot;PetModelContainer&quot; connectionString=&quot;metadata=res://*/PetModel.csdl|res://*/PetModel.ssdl|res://*/PetModel.msl;provider=System.Data.SqlClient; provider connection string=&amp;quot;data source=.; initial catalog=DemoDb; integrated security=True; multipleactiveresultsets=True; App=EntityFramework&amp;quot;&quot; providerName=&quot;System.Data.EntityClient&quot; /&gt;
&lt;add name=&quot;PetDb&quot; connectionString=&quot;data source=.; initial catalog=DemoDb; integrated security=True;&quot; /&gt;
&lt;/connectionStrings&gt;
</pre></p>
</div>
<p>I was now ready to consume the SQL script and create the database tables. The follow code instantiates a database connection, loads the database script from the file system into a SqlCommand object, and executes the command. Note that unlike Windows Azure, an Iron Foundry web application CAN use file system operations.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:c9b0fd57-cb2e-4267-8d7d-c840e3acd198" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
//create connection
            string connString = ConfigurationManager.ConnectionStrings[&quot;PetDb&quot;].ConnectionString;
            SqlConnection c = new SqlConnection(connString);

            //load generated SQL script into a string
            FileInfo file = new FileInfo(Server.MapPath(&quot;PetModel.edmx.sql&quot;));
            string tableScript = file.OpenText().ReadToEnd();

            c.Open();
            //execute sql script and create tables
            SqlCommand command = new SqlCommand(tableScript, c);
            command.ExecuteNonQuery();
            file.OpenText().Close();
            c.Close();

            command.Dispose();
            c.Dispose();

            lblStatus.Text = &quot;db table created&quot;;
</pre></p>
</div>
<p>Cool. So after this runs, we should have real database tables in our LOCAL database. Next up, I wrote the code necessary to add some sample data into our tables</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:81d05ae0-bd5d-499c-bac1-14734549c186" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; wrap-lines: false;">
 //create connection
            string connString = ConfigurationManager.ConnectionStrings[&quot;PetDb&quot;].ConnectionString;
            SqlConnection c = new SqlConnection(connString);
            c.Open();

            string commandString = &quot;&quot;;
            SqlCommand command;
            string ownerId;
            string petId;

            //owner command
            commandString = &quot;INSERT INTO Owners VALUES ('Richard Seroter', '818-232-5454', 0);SELECT SCOPE_IDENTITY();&quot;;
            command = new SqlCommand(commandString, c);
            ownerId = command.ExecuteScalar().ToString();

            //pet command
            commandString = &quot;INSERT INTO Pets VALUES ('Watson', 'Dog', 'Corgador', '31 lbs', 'Do not feed wet food', &quot; + ownerId + &quot;);SELECT SCOPE_IDENTITY();&quot;;
            command = new SqlCommand(commandString, c);
            petId = command.ExecuteScalar().ToString();

 		//add more rows

		c.Close();
            command.Dispose();
            c.Dispose();

            lblStatus.Text = &quot;rows added&quot;;
</pre></p>
</div>
<h3>Step 4: Local Testing</h3>
<p>I’m ready to test this application. After pressing F5 in Visual Studio 2010 and running this web application in a local web server, I saw my Web Form buttons for creating tables and seeding data. After clicking the <strong>Create Database</strong> button, I checked my local SQL Server. Sure enough, I found my new tables.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry07.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry07" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry07_thumb.png?w=232&#038;h=130" alt="2012.1.16ironfoundry07" width="232" height="130" border="0" /></a></p>
<p>Next, I clicked the <strong>Seed Data </strong>button on my form and saw three rows added to each table. With my tables ready and data loaded, I could now execute the OData service. Hitting the service address resulted in a list of entities that the service makes available.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry08.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry08" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry08_thumb.png?w=433&#038;h=307" alt="2012.1.16ironfoundry08" width="433" height="307" border="0" /></a></p>
<p>And then, per typical OData queries, I could drill into the various entities and relationship. With this simple query, I can show all the pets for a particular owner.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry09.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry09" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry09_thumb.png?w=450&#038;h=385" alt="2012.1.16ironfoundry09" width="450" height="385" border="0" /></a></p>
<p>At this point, I had a fully working, LOCAL version of the this application.</p>
<h3>Step 5: Deploy to Iron Foundry</h3>
<p>Here’s where the rubber meets the road. Can I take this app, as is, and have it work in Iron Foundry? This answer is “pretty much.” The only thing that I really need to do is update the connection string for my Iron Foundry instance of SQL Server, but I’m getting ahead of myself. I first had to get this application up to Iron Foundry so that I could associate it with a SQL instance. Since I’ve had some instability with the Visual Studio plugin for Iron Foundry, I went ahead and “published” my ASP.NET application to my file system and ran the vmc client to upload the application.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry11.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry11" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry11_thumb.png?w=450&#038;h=280" alt="2012.1.16ironfoundry11" width="450" height="280" border="0" /></a></p>
<p>With my app uploaded, I then bound my application to a SQL Server application service. I used the <strong>bind-service</strong> command to bind my SQL Server service to my application.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry14.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry14" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry14_thumb.png?w=450&#038;h=468" alt="2012.1.16ironfoundry14" width="450" height="468" border="0" /></a></p>
<p>Now I needed to view my web.config file that was modified by the Iron Foundry engine. When this binding occurred, Iron Foundry provisioned a SQL Server space for me and updated my web.config file with the valid connection string. I’m going to need those connection string values (server name, database name, credentials) for my application as well. I wasn’t sure how to access my application files from the vmc tool, so I switched back to the Cloud Explorer where I can actually browse an app.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry15.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry15" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry15_thumb.png?w=262&#038;h=204" alt="2012.1.16ironfoundry15" width="262" height="204" border="0" /></a></p>
<p>My web.config file now contained a “Default” connection string added by Iron Foundry.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:b4025de5-db70-4333-a671-8dfdb054197c" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: xml; highlight: [5]; pad-line-numbers: true; wrap-lines: false;">
&lt;connectionStrings&gt;
    &lt;add name=&quot;PetModelContainer&quot; connectionString=&quot;metadata=res://*/PetModel.csdl|res://*/PetModel.ssdl|res://*/PetModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=.;initial catalog=DemoDb;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&amp;quot;&quot;
      providerName=&quot;System.Data.EntityClient&quot; /&gt;
    &lt;add name=&quot;PetDb&quot; connectionString=&quot;data source=.;initial catalog=DemoDb;integrated security=True;&quot; /&gt;
    &lt;add name=&quot;Default&quot; connectionString=&quot;Data Source=XXXXXX;Initial Catalog=YYYYYYY;Integrated Security=False;User ID=ABC;Password=DEF;Connect Timeout=30&quot; /&gt;
  &lt;/connectionStrings&gt;
</pre></p>
</div>
<h3>Step 6: Update Application with Iron Foundry Connection Details and then Test the Solution</h3>
<p>With these connection string values in hand, I had two things to update. First, I updated my generated T-SQL script to “use” the appropriate database.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry16.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry16" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry16_thumb.png?w=450&#038;h=280" alt="2012.1.16ironfoundry16" width="450" height="280" border="0" /></a></p>
<p>Finally, I had to update the two previously created connection strings. I updated my ORIGINAL web.config and not the one that I retrieved back from Iron Foundry. The first (“PetDb”) connection string was used by my code to run the T-SQL script and create the tables, and the second connection string (“PetModelContainer”) is leveraged by the Entity Framework and the WCF Data Service. Both were updated with the Iron Foundry connection string details.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:056c980a-f89e-4211-85db-a54779f8a9d3" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: xml; highlight: [2,4]; wrap-lines: false;">
&lt;connectionStrings&gt;
    &lt;add name=&quot;PetModelContainer&quot; connectionString=&quot;metadata=res://*/PetModel.csdl|res://*/PetModel.ssdl|res://*/PetModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=XXXXX;initial catalog=YYYYYY;Integrated Security=False;User ID=ABC;Password=DEF;multipleactiveresultsets=True;App=EntityFramework&amp;quot;&quot;
      providerName=&quot;System.Data.EntityClient&quot; /&gt;
    &lt;add name=&quot;PetDb&quot; connectionString=&quot;data source=XXXXX;initial catalog=YYYYYY;Integrated Security=False;User ID=ABC;Password=DEF;&quot; /&gt;
   &lt;/connectionStrings&gt;
</pre></p>
</div>
<p>With these updates in place, I rebuilt the application and pushed a new version of my application up to Iron Foundry.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry17.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry17" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry17_thumb.png?w=450&#038;h=197" alt="2012.1.16ironfoundry17" width="450" height="197" border="0" /></a></p>
<p>I was now ready to test this cat out. As expected, I could now hit the public URL of my “setup” page (which I have since removed so that you can’t create tables over and over!).</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry18.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry18" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry18_thumb.png?w=450&#038;h=160" alt="2012.1.16ironfoundry18" width="450" height="160" border="0" /></a></p>
<p>After creating the database (via <strong>Create Database</strong> button), I then clicked the button to load a few rows of data into my database tables.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry19.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry19" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry19_thumb.png?w=450&#038;h=180" alt="2012.1.16ironfoundry19" width="450" height="180" border="0" /></a></p>
<p>For the grand finale, I tested my OData service which should allow me to query my new SQL Server database tables. Hitting the URL <a title="http://seroterodata.gofoundry.net/PetService.svc/Pets" href="http://seroterodata.gofoundry.net/PetService.svc/Pets">http://seroterodata.gofoundry.net/PetService.svc/Pets</a> returns a list of all the Pets in my database.</p>
<p><a href="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry20.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2012.1.16ironfoundry20" src="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry20_thumb.png?w=450&#038;h=364" alt="2012.1.16ironfoundry20" width="450" height="364" border="0" /></a></p>
<p>As with any OData service, you can now <a href="http://www.odata.org/developers/protocols/uri-conventions" target="_blank">mess with the data in all sorts of ways</a>. This URL (<a title="http://seroterodata.gofoundry.net/PetService.svc/Pets(2)/Owner" href="http://seroterodata.gofoundry.net/PetService.svc/Pets(2)/Owner">http://seroterodata.gofoundry.net/PetService.svc/Pets(2)/Owner</a>) returns the owner of the second pet. If I want to show the owner and pet in a single result set, I can use this URL (<a title="http://seroterodata.gofoundry.net/PetService.svc/Owners(1)?$expand=Pets" href="http://seroterodata.gofoundry.net/PetService.svc/Owners(1)?$expand=Pets">http://seroterodata.gofoundry.net/PetService.svc/Owners(1)?$expand=Pets</a>). Want the name of the 3rd pet? use this URL (<a title="http://seroterodata.gofoundry.net/PetService.svc/Pets(3)/Name" href="http://seroterodata.gofoundry.net/PetService.svc/Pets(3)/Name">http://seroterodata.gofoundry.net/PetService.svc/Pets(3)/Name</a>).</p>
<h3>Summary</h3>
<p>Overall, this is fairly straightforward stuff. I definitely felt a bit handicapped by not being able to directly use SQL Server Management Studio, but at least it forced me to brush up on my T-SQL commands. One interesting item was that it APPEARS that I am provisioned a single database when I first bind to an application service and that same database is used for subsequent bindings. I had built a previous application that used the SQL Server application service and later deleted the app. When I deployed the application above, I noticed that the tables I had created earlier were still there! So, whether intentionally or not, Iron Foundry points me to the same (personal?) database for each app. Not a big deal, but this could have unintended side effects if you’re not aware of it.</p>
<p>Right now, developers can use either the SQL Server application service or MongoDB application service. Expect to see more show up in the near future. While you need to programmatically provision your database resources, that doesn’t seem to be a big deal. The Iron Foundry application services are a critical resource in building truly interesting web applications and I hope you enjoyed this walkthrough.</p>
<br />Filed under: <a href='http://seroter.wordpress.com/category/cloud/'>Cloud</a>, <a href='http://seroter.wordpress.com/category/cloud-foundry/'>Cloud Foundry</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seroter.wordpress.com/1955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seroter.wordpress.com/1955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seroter.wordpress.com/1955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seroter.wordpress.com/1955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seroter.wordpress.com/1955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seroter.wordpress.com/1955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seroter.wordpress.com/1955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seroter.wordpress.com/1955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seroter.wordpress.com/1955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seroter.wordpress.com/1955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seroter.wordpress.com/1955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seroter.wordpress.com/1955/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seroter.wordpress.com/1955/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seroter.wordpress.com/1955/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1955&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seroter.wordpress.com/2012/01/24/building-an-odata-web-service-on-iron-foundry/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ef5fd2c721814f5491c1f6bfdadf4753?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">rseroter</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry01_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry01</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry02_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry02</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry03_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry03</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry04_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry04</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry12_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry12</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry05_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry05</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry06_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry06</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry07_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry07</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry08_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry08</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry09_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry09</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry11_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry11</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry14_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry14</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry15_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry15</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry16_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry16</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry17_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry17</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry18_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry18</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry19_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry19</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2012/01/2012-1-16ironfoundry20_thumb.png" medium="image">
			<media:title type="html">2012.1.16ironfoundry20</media:title>
		</media:content>
	</item>
		<item>
		<title>Watch the First Module Of My StreamInsight Course &#8230; For Free</title>
		<link>http://seroter.wordpress.com/2012/01/16/watch-the-first-module-of-my-streaminsight-course-for-free/</link>
		<comments>http://seroter.wordpress.com/2012/01/16/watch-the-first-module-of-my-streaminsight-course-for-free/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 15:57:51 +0000</pubDate>
		<dc:creator>Richard Seroter</dc:creator>
				<category><![CDATA[StreamInsight]]></category>

		<guid isPermaLink="false">https://seroter.wordpress.com/?p=1912</guid>
		<description><![CDATA[I recently authored and published a Pluralsight course on StreamInsight. As part of a marketing agreement between Microsoft and Pluralsight, the first module of this course is now available on Microsoft’s TechNet site. On the middle right of the page, you’ll see a promo section where you can launch this introductory module. No sign up, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1912&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently authored and published a <a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=streaminsight" target="_blank">Pluralsight course on StreamInsight</a>. As part of a marketing agreement between Microsoft and Pluralsight, the first module of this course is now <a href="http://technet.microsoft.com/en-us/sqlserver/ff655017" target="_blank">available on Microsoft’s TechNet site</a>. On the middle right of the page, you’ll see a promo section where you can launch this introductory module. <strong>No sign up, no email address required, nothing</strong>. Just click and watch.</p>
<p>If you’ve been curious about what StreamInsight is, or have an odd interest in hearing me speak, now’s the time to indulge yourself. If you like where the course is going, I’d strongly encourage you to sign up for a Pluralsight subscription, which is one of the best investments that a developer can make.</p>
<br />Filed under: <a href='http://seroter.wordpress.com/category/streaminsight/'>StreamInsight</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seroter.wordpress.com/1912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seroter.wordpress.com/1912/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seroter.wordpress.com/1912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seroter.wordpress.com/1912/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seroter.wordpress.com/1912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seroter.wordpress.com/1912/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seroter.wordpress.com/1912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seroter.wordpress.com/1912/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seroter.wordpress.com/1912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seroter.wordpress.com/1912/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seroter.wordpress.com/1912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seroter.wordpress.com/1912/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seroter.wordpress.com/1912/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seroter.wordpress.com/1912/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1912&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seroter.wordpress.com/2012/01/16/watch-the-first-module-of-my-streaminsight-course-for-free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ef5fd2c721814f5491c1f6bfdadf4753?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">rseroter</media:title>
		</media:content>
	</item>
		<item>
		<title>Interview Series: Four Questions With &#8230; Paul Somers</title>
		<link>http://seroter.wordpress.com/2012/01/09/interview-series-four-questions-with-paul-somers/</link>
		<comments>http://seroter.wordpress.com/2012/01/09/interview-series-four-questions-with-paul-somers/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 13:13:46 +0000</pubDate>
		<dc:creator>Richard Seroter</dc:creator>
				<category><![CDATA[BizTalk]]></category>
		<category><![CDATA[Four Questions]]></category>

		<guid isPermaLink="false">https://seroter.wordpress.com/?p=1904</guid>
		<description><![CDATA[Happy New Year and welcome to my 37th interview with a thought leader in the “connected systems” space. This month, we’re chatting with Paul Somers who is a consultant, Microsoft MVP,  blogger, and speaker. Paul is well-known in the BizTalk community, so let’s pick his brain on the topic of integration. Q: Are you seeing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1904&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Happy New Year and welcome to my <a href="http://seroter.wordpress.com/category/four-questions/" target="_blank">37th interview</a> with a thought leader in the “connected systems” space. This month, we’re chatting with Paul Somers who is a consultant, <a href="https://mvp.support.microsoft.com/profile/Paul.Somers" target="_blank">Microsoft MVP</a>,  <a href="http://paulsomers.blogspot.com/" target="_blank">blogger</a>, and speaker. Paul is well-known in the BizTalk community, so let’s pick his brain on the topic of integration.</p>
<div style="border:black 1px solid;padding:4px 8px;">
<p><strong>Q: Are you seeing any change in the types of BizTalk projects that you work on? Are you using web services more than you did 3 years ago? More or less orchestration?</strong></p>
<p><strong>A: </strong>Not really, the same problems exist as before, orchestrations are a must have. Many organizations are doing EAI types of projects, sorting out their internal apps, with some of these projects hitting an external entity. Some with web services, but there are cloud based providers that do NOT provide web services to communicate with. It’s much more painful when you have to talk to a client app, which then talks to the server/cloud by using some OTHER method of communication. All in all the number of web services has stayed the same.</p>
<p><strong>Q: <strong>Kent Weare<a href="http://middlewareinthecloud.com/2011/12/17/azure-service-bus-eaiedi-december-2011-ctp-new-mapper/"> recently showed off</a> some of the new Mapper capabilities in the Azure AppFabric EAI/EDI CTP. Which of those new functoids look most useful to you, and why?</strong></strong></p>
<p><strong>A: </strong><strong></strong>I like the new string manipulation functiods, however the one we use the most, and is not there is the scripting functiod, as there is no functiod, and I don’t want one, that can apply complex business logic, best expressed in code, based on three elements in the source schema, to produce a single result in the destination schema.</p>
<p><strong>Q: <strong>I like one of the points made in a recent InfoQ.com article (<a href="http://www.infoq.com/articles/everything-is-paasible">Everything is PaaSible</a>) where the author says that sometimes, having so many tools is a hindrance and it&#8217;s better to just &#8220;make do&#8221; with existing platforms and products instead of incurring the operational overhead of introducing new things.  Where in BizTalk projects do you err on the side of simplicity, instead of adding yet another component to the solution?</strong></strong></p>
<p><strong>A: </strong>Well it’s quite simple actually, where some organizations try and sweep it clean and put in an application that will do the job of several of their existing applications, I have seen the result to business when this occurs, it’s almost disaster for the company for a period of time.  The article suggests the right tool for the right job, BizTalk is that tool… as I have found that the better and often simpler approach is to integrate, with BizTalk, we simply slip it in, and get it communication with the other applications, sharing the information, automating the processes, where they would print it out of the one system and enter it into the other, now instantly as soon as it’s in the one system, it comes up not too much later in the other system, depends on the system, however there should also be a big move from batch based interactions, to more real time, or what I like to say, “NEAR” real time systems, that within a few minutes the other system will contain the same information as the other system.</p>
<p><strong>Q [stupid question]: <strong>As 2011 ends and 2012 begins, many people focus on the things they did in the previous year.  However, what are the things you are proud of NOT doing in 2011?  For me, I&#8217;m proud of myself for never &#8220;<a href="http://en.wikipedia.org/wiki/Planking_%28fad%29">planking</a>&#8221; or using the acronym &#8220;LOL&#8221; in any form of writing (until now, I guess). You?</strong></strong></p>
<p><strong>A: </strong>I’m proud in some way, of not moving a single customer to the cloud for the right reason. We are not moving our customers to a cloud based approach, we have ZERO uptake of customers who will move their critical data to the cloud, their sensitive data to the cloud, no matter how secure these companies say it is, unless it’s secure inside their building, their firewall, and their organization, they really have no way of securing the data, and rightly so they WILL NOT move it to the cloud. I deal with many financial transactions, confidential information, such as the pay grade, and bonus amount of every employee in the organisation, to what orders are coming in from who. ALL of this is critical and sensitive information, which in the hands of the wrong person could expose the organization.  This is a real problem for me, because there is no hybrid system, where I can develop it on site, and then move selective bits where processing is critical, say one orchestration that we get millions of instances, would be best served in a cloud based approach. I simply can’t do this, and sadly I don’t see anyone catering for this scenario, which is perhaps the single most likely instance of using the cloud. I want to use it more, but I’m driven by what my clients want, and they say no, and quite rightly so.</p>
</div>
<p>Thanks Paul!</p>
<br />Filed under: <a href='http://seroter.wordpress.com/category/biztalk/'>BizTalk</a>, <a href='http://seroter.wordpress.com/category/four-questions/'>Four Questions</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seroter.wordpress.com/1904/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seroter.wordpress.com/1904/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seroter.wordpress.com/1904/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seroter.wordpress.com/1904/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seroter.wordpress.com/1904/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seroter.wordpress.com/1904/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seroter.wordpress.com/1904/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seroter.wordpress.com/1904/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seroter.wordpress.com/1904/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seroter.wordpress.com/1904/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seroter.wordpress.com/1904/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seroter.wordpress.com/1904/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seroter.wordpress.com/1904/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seroter.wordpress.com/1904/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1904&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seroter.wordpress.com/2012/01/09/interview-series-four-questions-with-paul-somers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ef5fd2c721814f5491c1f6bfdadf4753?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">rseroter</media:title>
		</media:content>
	</item>
		<item>
		<title>2011 Year in Review</title>
		<link>http://seroter.wordpress.com/2011/12/30/2011-year-in-review/</link>
		<comments>http://seroter.wordpress.com/2011/12/30/2011-year-in-review/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 15:48:13 +0000</pubDate>
		<dc:creator>Richard Seroter</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">https://seroter.wordpress.com/?p=1897</guid>
		<description><![CDATA[2011 was an interesting year. I added 47 posts to this blog, produced three training courses for Pluralsight, started contributing a pair of articles per month for InfoQ.com, released my 3rd book, had speaking engagements in New Zealand, Sweden and China, started graduate school, and accepted a new job. I’m extremely thankful for all these [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1897&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>2011 was an interesting year. I added 47 posts to this blog, <a href="http://www.pluralsight-training.net/microsoft/Authors/Details?handle=richard-seroter" target="_blank">produced three training courses</a> for Pluralsight, started contributing <a href="http://www.infoq.com/author/Richard-Seroter" target="_blank">a pair of articles per month</a> for InfoQ.com, released <a href="http://www.amazon.com/gp/product/1849681902/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=217153&amp;creative=399701&amp;creativeASIN=1849681902" target="_blank">my 3rd book</a>, had speaking engagements in New Zealand, Sweden and China, started <a href="http://cuengineeringonline.colorado.edu/degrees/engineering-management" target="_blank">graduate school</a>, and <a href="http://seroter.wordpress.com/2011/09/02/new-job-same-place/" target="_blank">accepted a new job</a>. I’m extremely thankful for all these opportunities and I keep doing all this stuff because I find it fun and love learning new things. And I really appreciate the 172,000+ visits to the blog this year and the many of you who bought my books, watched my training and read my InfoQ articles.</p>
<p>In this post, I’m going to highlight some of my favorite blog posts and books from 2011.</p>
<p>First off, these are a few blog posts that I enjoyed writing this year.</p>
<ul>
<li><a href="http://seroter.wordpress.com/2011/07/14/is-biztalk-server-going-away-at-some-point-yes-dead-nope/" target="_blank">Is BizTalk Server Going Away At Some Point? Yes. Dead? Nope</a>. I think this was the first blog post that I’ve written that ever went viral. I wrote this in my head on the way to work one morning and apparently it resonated with a lot of people.</li>
<li><a href="http://seroter.wordpress.com/2011/02/10/the-good-bad-and-ugly-of-integrating-dynamics-crm-2011-and-biztalk-server-2010/" target="_blank">The Good, Bad and Ugly of Integrating Dynamics CRM 2011 and BizTalk Server 2010</a>. This has inexplicably become one of the most popular posts that I’ve ever written.</li>
<li><a href="http://seroter.wordpress.com/2011/04/03/using-the-biztalk-adapter-pack-and-appfabric-connect-in-a-workflow-service/" target="_blank">Using the BizTalk Adapter Pack and AppFabric Connect in a Workflow Service</a>. This was one of the demonstrations from my New Zealand trip and I thought it was a cool way to do lightweight, stateful LOB communication.</li>
<li><a href="http://seroter.wordpress.com/2011/05/11/6-quick-steps-for-windows-net-folks-to-try-out-cloud-foundry/" target="_blank">6 Quick Steps for Windows/.NET Folks to Try Out Cloud Foundry</a>. Lots of changes to cloud offerings in 2011 and in hindsight, I’m glad I looked into Cloud Foundry. It’s a cool platform and we’ll likely be hearing much more about it in 2012.</li>
<li>It was fun to dig into the WCF Routing Service in a <a href="http://seroter.wordpress.com/2011/01/09/wcf-routing-service-deep-dive-part-icomparing-to-biztalk-server/" target="_blank">pair</a> of <a href="http://seroter.wordpress.com/2011/01/13/wcf-routing-service-deep-dive-part-iiusing-filters/" target="_blank">posts</a>. I’m not sure if this is heavily used software, but it definitely adds value in simple routing scenarios.</li>
<li><a href="http://seroter.wordpress.com/2011/06/27/sending-messages-from-salesforce-com-to-biztalk-server-through-windows-azure-appfabric/" target="_blank">Sending Messages from Salesforce.com to BizTalk Server Through Windows Azure AppFabric</a>. I built this demo for the last book, and still think it’s a really neat way to run cloud apps but leverage onsite services.</li>
<li>I had a good time exploring a pre-release version of StreamInsight Austin (“StreamInsight in the cloud”) and showed how to <a href="http://seroter.wordpress.com/2011/07/13/event-processing-in-the-cloud-with-streaminsight-austin-part-i-building-an-azure-appfabric-adapter/" target="_blank">build an internet-friendly adapter</a> and then how to <a href="http://seroter.wordpress.com/2011/07/18/event-processing-in-the-cloud-with-streaminsight-austin-part-ii-deploying-to-windows-azure/" target="_blank">deploy a cloud CEP app</a>.</li>
<li><a href="http://seroter.wordpress.com/2011/10/28/integration-in-the-cloud-part-1-introduction/" target="_blank">Integration in the Cloud</a>. This four-part series was the basis for my presentation at QCon Hangzhou and I enjoyed applying well-known patterns to cloud scenarios.</li>
<li><a href="http://seroter.wordpress.com/2011/12/13/first-look-deploying-net-web-apps-to-cloud-foundry-via-iron-foundry/" target="_blank">First Look: Deploying .NET Web Apps to Cloud Foundry via Iron Foundry</a>. If we assume that PaaS is the future of cloud computing, I suspect that Azure will be just one of the places that developers deploy .NET web applications to.</li>
<li>I really enjoyed each of the “4 Questions” interviews in 2011 and had a blast talking to <a href="http://seroter.wordpress.com/2011/01/31/interview-series-four-questions-with-rick-garibay/" target="_blank">Rick Garibay</a>, <a href="http://seroter.wordpress.com/2011/03/02/interview-series-four-questions-with-steef-jan-wiggers/" target="_blank">Steef-Jan Wiggers</a>, <a href="http://seroter.wordpress.com/2011/04/04/interview-series-four-questions-with-jon-fancey/" target="_blank">Jon Fancey</a>,  <a href="http://seroter.wordpress.com/2011/05/02/interview-series-four-questions-with-buck-woody/" target="_blank">Buck Woody</a>, <a href="http://seroter.wordpress.com/2011/06/02/interview-series-four-questions-with-sam-vanhoutte/" target="_blank">Sam Vanhoutte</a>, <a href="http://seroter.wordpress.com/2011/07/05/interview-series-four-questions-with-pablo-cibraro/" target="_blank">Pablo Cibraro</a>, <a href="http://seroter.wordpress.com/2011/08/01/interview-series-four-questions-with-allan-mitchell/" target="_blank">Allan Mitchell</a>, <a href="http://seroter.wordpress.com/2011/09/01/interview-series-four-questions-with-ryan-crawcour/" target="_blank">Ryan CrawCour</a>, <a href="http://seroter.wordpress.com/2011/10/03/interview-series-four-questions-with-scott-seely/" target="_blank">Scott Seely</a>, and <a href="http://seroter.wordpress.com/2011/12/01/interview-series-four-questions-with-clemens-vasters/" target="_blank">Clemens Vasters</a>.</li>
</ul>
<p>It was hard to keep up my regular pace of reading a book or two a month, but I still carved out time to read some memorable ones. I admittedly read fewer deep technical books and focused more on growing as a strategist and learning to manage my time effectively.  Here are a few of my favorites from this year:</p>
<ul>
<li><a href="http://www.amazon.com/gp/product/0061771295/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0061771295" target="_blank">Your Brain at Work</a>. Great description of what tasks tax the brain most, how to decompose complex ideas, strategies for staying focused and how to be more mindful. Useful stuff.</li>
<li><a href="http://www.amazon.com/gp/product/0316010669/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0316010669" target="_blank">Blink</a>. Gladwell is known for writing provocative books, and this is no exception.  Instead of thinking that the quality of our decisions are based on the time/effort we put into it, we should trust our judgment more often.</li>
<li><a href="http://www.amazon.com/gp/product/0806531436/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0806531436" target="_blank">The Bullpen Gospels</a>. I’m a sucker for baseball books, and this one was immensely satisfying.  It’s a great story of a pitcher’s journey through minor league baseball.</li>
<li><a href="http://www.amazon.com/gp/product/1936719010/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1936719010" target="_blank">Do the Work</a>. Nice little book that encourages us to jump into a task, not fear success, and to remember that “finishing” is the most critical part of a project.</li>
<li><a href="http://www.amazon.com/gp/product/0321704452/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321704452" target="_blank">The Naked Presenter: Delivering Powerful Presentations With or Without Slides</a>. I’ve worked at becoming a better presenter over the past few years, and books like this help keep me focused on telling a compelling story without using slides as a crutch.</li>
<li><a href="http://www.amazon.com/gp/product/0977140032/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0977140032" target="_blank">fruITion: Creating the Ultimate Corporate Strategy for Information Technology</a>. Good read about articulating the real role of IT in an organization and the value of better alignment with business partners.</li>
<li><a href="http://www.amazon.com/gp/product/1935504088/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1935504088" target="_blank">recrEAtion: Realizing the Extraordinary Contribution of Your Enterprise Architects</a>. If you’re an architect, or even pretend to be one, this is a must-read.  Fundamentally changed my thinking on what it means to be an (enterprise) architect. Continues the fictitious story from the previous book, <strong>fruITion</strong>.</li>
<li><a href="http://www.amazon.com/gp/product/1439170428/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1439170428" target="_blank">Little Bets</a>. Food for thought about the value of experimentation as most new brilliant ideas don’t form out of thin air, but are discovered.</li>
<li><a href="http://www.amazon.com/gp/product/0553386794/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0553386794" target="_blank">Game of Thrones</a>; <a href="http://www.amazon.com/gp/product/0553579908/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0553579908" target="_blank">A Clash of Kings</a>; <a href="http://www.amazon.com/gp/product/0553381709/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0553381709" target="_blank">A Storm of Swords</a>. I’m not a fantasy book guy, but after watching Game of Thrones on HBO, I thought I’d try the books. I read the first three and loved the characters and “did they really do that?” plot twists.</li>
<li><a href="http://www.amazon.com/gp/product/0307887650/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0307887650" target="_blank">The Two Second Advantage: How We Succeed by Anticipating the Future&#8211;Just Enough</a>. Excellent book on the real-time data revolution. Although written by the CEO of TIBCO, the book isn’t very technical but rather shows the reader the significant impact of real-time intelligence.</li>
<li><a href="http://www.amazon.com/gp/product/0812975707/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0812975707" target="_blank">A. Lincoln: A Biography</a>. Fascinating, well-paced story of one of America’s most compelling historical figures. Lincoln was such a deep thinker and this book does an excellent job following his thoughts from early life through his successful navigation of the US Civil War.</li>
</ul>
<p>As for 2012, hopefully you’ll see more blog posts, more training courses, and more interviews containing stupid questions.</p>
<br />Filed under: <a href='http://seroter.wordpress.com/category/general/'>General</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seroter.wordpress.com/1897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seroter.wordpress.com/1897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seroter.wordpress.com/1897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seroter.wordpress.com/1897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seroter.wordpress.com/1897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seroter.wordpress.com/1897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seroter.wordpress.com/1897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seroter.wordpress.com/1897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seroter.wordpress.com/1897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seroter.wordpress.com/1897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seroter.wordpress.com/1897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seroter.wordpress.com/1897/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seroter.wordpress.com/1897/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seroter.wordpress.com/1897/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1897&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seroter.wordpress.com/2011/12/30/2011-year-in-review/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ef5fd2c721814f5491c1f6bfdadf4753?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">rseroter</media:title>
		</media:content>
	</item>
		<item>
		<title>Sending Messages to Azure AppFabric Service Bus Topics From Iron Foundry</title>
		<link>http://seroter.wordpress.com/2011/12/27/sending-messages-to-azure-appfabric-service-bus-topics-from-iron-foundry/</link>
		<comments>http://seroter.wordpress.com/2011/12/27/sending-messages-to-azure-appfabric-service-bus-topics-from-iron-foundry/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 09:28:32 +0000</pubDate>
		<dc:creator>Richard Seroter</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Cloud Foundry]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Windows Azure AppFabric]]></category>

		<guid isPermaLink="false">https://seroter.wordpress.com/?p=1888</guid>
		<description><![CDATA[I recently took a look at Iron Foundry and liked what I found.  Let’s take a bit of a deeper look into how to deploy Iron Foundry .NET solutions that reference additional components.  Specifically, I’ll show you how to use the new Windows Azure AppFabric brokered messaging to reliably send messages from Iron Foundry to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1888&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently <a href="http://seroter.wordpress.com/2011/12/13/first-look-deploying-net-web-apps-to-cloud-foundry-via-iron-foundry/" target="_blank">took a look at Iron Foundry</a> and liked what I found.  Let’s take a bit of a deeper look into how to deploy Iron Foundry .NET solutions that reference additional components.  Specifically, I’ll show you how to use the new Windows Azure AppFabric brokered messaging to reliably send messages from Iron Foundry to an on-premises application.</p>
<p>The <a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=27421" target="_blank">Azure AppFabric v1.5 release</a> contains useful Service Bus capabilities for durable messaging communication through the use of Queues and Topics. The Service Bus still has the Relay Service which is great for invoking services through a cloud relay, but the asynchronous communication through the Relay Service isn’t durable.  Queues and Topics now let you send messages to one or many subscribers and have stronger guarantees of delivery.</p>
<p>An Iron Foundry application is just a standard .NET web application.  So, I’ll start with a blank ASP.NET web application and use old-school Web Forms instead of MVC. We need a reference to the Microsoft.ServiceBus.dll that comes with Azure AppFabric v1.5.  With that reference added, I added a new Web Form and included the necessary “using” statements.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry01.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="2011.12.23ironfoundry01" src="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry01_thumb.png?w=357&#038;h=121" alt="2011.12.23ironfoundry01" width="357" height="121" border="0" /></a></p>
<p>I then built a very simple UI on the Web Form that takes in a handful of values that will be sent to the on-premises subscriber(s) through the Service Bus. Before creating the code that sends a message to a Topic, I defined an “Order” object that represents the data being sent to the topic. This object sits in a shared assembly used by this application that sends the message, and another application that receives a message.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:952e739c-af8b-4254-82b6-c33940d87f34" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; pad-line-numbers: true;">
[DataContract]
    public class Order
    {
        [DataMember]
        public string Id { get; set; }
        [DataMember]
        public string ProdId { get; set; }
        [DataMember]
        public string Quantity { get; set; }
        [DataMember]
        public string Category { get; set; }
        [DataMember]
        public string CustomerId { get; set; }
    }
</pre></p>
</div>
<p>The “submit” button on the Web Form triggers a click event that contains a flurry of activities.  At the beginning of that click handler, I defined some variables that will be used throughout.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:db4552d8-32b4-42d8-a068-1b52f8862563" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; pad-line-numbers: true;">
//define my personal namespace
string sbNamespace = &quot;richardseroter&quot;;
//issuer name and key
string issuer = &quot;MY ISSUER&quot;;
string key = &quot;MY PRIVATE KEY&quot;;

//set the name of the Topic to post to
string topicName = &quot;OrderTopic&quot;;
//define a variable that holds messages for the user
string outputMessage = &quot;result: &quot;;
</pre></p>
</div>
<p>Next I defined a <a href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.tokenprovider.aspx" target="_blank">TokenProvider</a> (to authenticate to my Topic) and a <a href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.namespacemanager.aspx" target="_blank">NamespaceManager</a> (which drives most of the activities with the Service Bus).</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:bf0ff6e0-d026-4242-82ff-f337ff9e6c04" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
//create namespace manager
TokenProvider tp = TokenProvider.CreateSharedSecretTokenProvider(issuer, key);
Uri sbUri = ServiceBusEnvironment.CreateServiceUri(&quot;sb&quot;, sbNamespace, string.Empty);
NamespaceManager nsm = new NamespaceManager(sbUri, tp);
</pre></p>
</div>
<p>Now we’re ready to either create a Topic or reference an existing one. If the Topic does NOT exist, then I went ahead and created it, along with two subscriptions.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:6dd709d0-aee9-411c-baf9-37047a26b660" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
//create or retrieve topic
bool doesExist = nsm.TopicExists(topicName);

if (doesExist == false)
   {
      //topic doesn't exist yet, so create it
      nsm.CreateTopic(topicName);

      //create two subscriptions

      //create subscription for just messages for Electronics
      SqlFilter eFilter = new SqlFilter(&quot;ProductCategory = 'Electronics'&quot;);
      nsm.CreateSubscription(topicName, &quot;ElecFilter&quot;, eFilter);

      //create subscription for just messages for Clothing
      SqlFilter eFilter2 = new SqlFilter(&quot;ProductCategory = 'Clothing'&quot;);
      nsm.CreateSubscription(topicName, &quot;ClothingFilter&quot;, eFilter2);

      outputMessage += &quot;Topic/subscription does not exist and was created; &quot;;
    }
</pre></p>
</div>
<p>At this point we either know that a topic exists, or we created one.  Next, I created a <a href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.messaging.messagesender.aspx" target="_blank">MessageSender</a> which will actually send a message to the Topic.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:da1ade12-4e35-4700-8db7-3f196338a508" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
//create objects needed to send message to topic
 MessagingFactory factory = MessagingFactory.Create(sbUri, tp);
 MessageSender orderSender = factory.CreateMessageSender(topicName);
</pre></p>
</div>
<p>We’re now ready to create the actual data object that we send to the Topic.  Here I referenced the Order object we created earlier.  Then I wrapped that Order in the <a href="http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.messaging.brokeredmessage.aspx" target="_blank">BrokeredMessage</a> object.  This object has a property bag that is used for routing.  I’ve added a property called “ProductCategory” that our Topic subscription uses to make decisions on whether to deliver the message to the subscriber or not.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:9ff6bc73-9184-4c96-b84e-c341c786ea73" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
//create order
Order o = new Order();
o.Id = txtOrderId.Text;
o.ProdId = txtProdId.Text;
o.CustomerId = txtCustomerId.Text;
o.Category = txtCategory.Text;
o.Quantity = txtQuantity.Text;

//create brokered message object
BrokeredMessage msg = new BrokeredMessage(o);
//add properties used for routing
msg.Properties[&quot;ProductCategory&quot;] = o.Category;
</pre></p>
</div>
<p>Finally, I send the message and write out the data to the screen for the user.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:6aed35bd-bc0f-4f2b-b60d-be16cb65fb33" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
//send it
orderSender.Send(msg);

outputMessage += &quot;Message sent; &quot;;
lblOutput.Text = outputMessage;
</pre></p>
</div>
<p>I decided to use the command line (Ruby-based) vmc tool to deploy this app to Iron Foundry.  So, I first published my website to a directory on the file system.  Then, I manually copied the Microsoft.ServiceBus.dll to the bin directory of the published site.  Let’s deploy! After logging into my production Iron Foundry account by targeting the api.gofoundry.net management endpoint, I executed a push command and instantly saw my web application move up to the cloud. It takes like 8 seconds from start to finish.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry02.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.23ironfoundry02" src="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry02_thumb.png?w=450&#038;h=236" alt="2011.12.23ironfoundry02" width="450" height="236" border="0" /></a></p>
<p>My site is now online and I can visit it and submit a new order [note that this site isn’t online now, so don’t try and flood my machine with messages!].  When I click the submit button, I can see that a new Topic was created by this application and a message was sent.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry03.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.23ironfoundry03" src="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry03_thumb.png?w=450&#038;h=327" alt="2011.12.23ironfoundry03" width="450" height="327" border="0" /></a></p>
<p>Let’s confirm that we really have a new Topic with subscriptions. I can first confirm this through the Windows Azure Management Console.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry04.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.23ironfoundry04" src="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry04_thumb.png?w=428&#038;h=252" alt="2011.12.23ironfoundry04" width="428" height="252" border="0" /></a></p>
<p>To see more details, I can use the <a href="http://msdn.microsoft.com/en-us/library/hh532261(VS.103).aspx" target="_blank">Service Bus Explorer</a> tool which allows us to browse our Service Bus configuration.  When I launch it, I can see that I have a Topic with a pair of subscriptions and even what Filter I applied.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry05.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.23ironfoundry05" src="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry05_thumb.png?w=450&#038;h=283" alt="2011.12.23ironfoundry05" width="450" height="283" border="0" /></a></p>
<p>I previously built a WinForm application that pulls data from an Azure AppFabric Service Bus Topic. When I click the “Receive Message” button, I pull a message from the Topic and we can see that it has the same Order ID as the message submitted from the website.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry06.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.23ironfoundry06" src="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry06_thumb.png?w=450&#038;h=465" alt="2011.12.23ironfoundry06" width="450" height="465" border="0" /></a></p>
<p>If I submit another message from the website, I see a different message because my Topic already exists and I’m simply reusing it.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry07.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.23ironfoundry07" src="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry07_thumb.png?w=421&#038;h=557" alt="2011.12.23ironfoundry07" width="421" height="557" border="0" /></a></p>
<h2>Summary</h2>
<p>So what did we see here?  First, I proved that an ASP.NET web application that you want to deploy to the Iron Foundry (onsite or offsite) cloud looks just like any other ASP.NET web application.  I didn’t have to build it differently or do anything special. Secondly, we saw that I can easily use the Windows Azure AppFabric Service Bus to reliably share data between a cloud-hosted application and an on-premises application.</p>
<br />Filed under: <a href='http://seroter.wordpress.com/category/cloud/'>Cloud</a>, <a href='http://seroter.wordpress.com/category/cloud-foundry/'>Cloud Foundry</a>, <a href='http://seroter.wordpress.com/category/soa/'>SOA</a>, <a href='http://seroter.wordpress.com/category/windows-azure/'>Windows Azure</a>, <a href='http://seroter.wordpress.com/category/windows-azure-appfabric/'>Windows Azure AppFabric</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seroter.wordpress.com/1888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seroter.wordpress.com/1888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seroter.wordpress.com/1888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seroter.wordpress.com/1888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seroter.wordpress.com/1888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seroter.wordpress.com/1888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seroter.wordpress.com/1888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seroter.wordpress.com/1888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seroter.wordpress.com/1888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seroter.wordpress.com/1888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seroter.wordpress.com/1888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seroter.wordpress.com/1888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seroter.wordpress.com/1888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seroter.wordpress.com/1888/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1888&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seroter.wordpress.com/2011/12/27/sending-messages-to-azure-appfabric-service-bus-topics-from-iron-foundry/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ef5fd2c721814f5491c1f6bfdadf4753?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">rseroter</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry01_thumb.png" medium="image">
			<media:title type="html">2011.12.23ironfoundry01</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry02_thumb.png" medium="image">
			<media:title type="html">2011.12.23ironfoundry02</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry03_thumb.png" medium="image">
			<media:title type="html">2011.12.23ironfoundry03</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry04_thumb.png" medium="image">
			<media:title type="html">2011.12.23ironfoundry04</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry05_thumb.png" medium="image">
			<media:title type="html">2011.12.23ironfoundry05</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry06_thumb.png" medium="image">
			<media:title type="html">2011.12.23ironfoundry06</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-23ironfoundry07_thumb.png" medium="image">
			<media:title type="html">2011.12.23ironfoundry07</media:title>
		</media:content>
	</item>
		<item>
		<title>My StreamInsight Course for Pluralsight is Now Available</title>
		<link>http://seroter.wordpress.com/2011/12/15/my-streaminsight-course-for-pluralsight-is-now-available/</link>
		<comments>http://seroter.wordpress.com/2011/12/15/my-streaminsight-course-for-pluralsight-is-now-available/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 08:11:40 +0000</pubDate>
		<dc:creator>Richard Seroter</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[StreamInsight]]></category>

		<guid isPermaLink="false">https://seroter.wordpress.com/?p=1858</guid>
		<description><![CDATA[I’ve been working for the past number of months on a comprehensive Pluralsight training course on Microsoft StreamInsight. I was hoping that I could bang out the course in a short amount of time, but I quickly learned that I needed to get much deeper into the product before I was comfortable producing credible training [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1858&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’ve been working for the past number of months on a comprehensive <a href="http://www.pluralsight-training.net/microsoft/" target="_blank">Pluralsight</a> training course on Microsoft <a href="http://www.microsoft.com/sqlserver/en/us/solutions-technologies/business-intelligence/complex-event-processing.aspx" target="_blank">StreamInsight</a>. I was hoping that I could bang out the course in a short amount of time, but I quickly learned that I needed to get much deeper into the product before I was comfortable producing credible training material.</p>
<p>The first seven modules of the course <strong>are now online</strong> at Pluralsight under the title <a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=streaminsight" target="_blank">StreamInsight Fundamentals</a>.  The final (yet to be finished) module will be on building resilient applications and leveraging the new checkpointing feature.  This is a complex topic, and I am building a full end to end demo from scratch, and didn’t want that holding up the primary modules of the course.</p>
<p>So what did I build? <a href="http://www.pluralsight-training.net/microsoft/Courses/TableOfContents?courseName=streaminsight" target="_blank">Seven modules totaling about 4 1/2 hours of content</a>.  Each module is very demo-heavy with a focus on realistic scenarios and none of the “let’s assume you have an object of type A with a property called Foo” stuff.</p>
<ul>
<li><strong>Module 1 – Introducing StreamInsight.</strong> This module is a brief introduction into event driven architecture, complex event processing and the basics of the StreamInsight product.</li>
<li><strong>Module 2 – Developing StreamInsight Queries</strong>. Lots of content here cover filtering, projection, event windows, grouping, aggregation, TopK, join, union and a host of timestamp modification examples. This is the longest module because it’s arguably the most important topic (but still watch the other ones!).</li>
<li><strong>Module 3 – Extending StreamInsight LINQ Queries.</strong> When out-of-the-box operators won’t do, build your own!  This module looks at all the supported ways to add extensions to StreamInsight LINQ.</li>
<li><strong>Module 4 – StreamInsight Event Sources: IObservable and IEnumerable.</strong> Here I walk through how to use both IObservable and IEnumerable objects as either the source or sink in a StreamInsight application.  The IObservable stuff was fun to build, but also took the longest for me to fully understand.</li>
<li><strong>Module 5 – StreamInsight Event Sources: Developing Adapters.</strong> This module covers the strategies and techniques for building both input and output adapters. Together we’ll build a typed MSMQ input adapter and an untyped MSMQ output adapter.  Good times will be had by all.</li>
<li><strong>Module 6 – Hosting StreamInsight Applications</strong>.  In this module, I show how to host StreamInsight within an application or by leveraging the standalone service.  I also go through a series of examples on how you chain queries (and streams) together and leverage their reusable nature.</li>
<li><strong>Module 7 – Monitoring and Troubleshooting StreamInsight Applications</strong>. Here I show all the ways to collect diagnostic data on StreamInsight applications and then go through event flow analysis using the Event Flow Debugger.</li>
</ul>
<p>All in all, it was fun thinking up the structure, preparing the material, building the demos, and producing the training videos.  There hasn’t been a whole lot of StreamInsight material out there, so hopefully this helps developers and architects who are trying to get up to speed on this very cool and powerful technology.</p>
<br />Filed under: <a href='http://seroter.wordpress.com/category/net/'>.NET</a>, <a href='http://seroter.wordpress.com/category/streaminsight/'>StreamInsight</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seroter.wordpress.com/1858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seroter.wordpress.com/1858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seroter.wordpress.com/1858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seroter.wordpress.com/1858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seroter.wordpress.com/1858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seroter.wordpress.com/1858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seroter.wordpress.com/1858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seroter.wordpress.com/1858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seroter.wordpress.com/1858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seroter.wordpress.com/1858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seroter.wordpress.com/1858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seroter.wordpress.com/1858/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seroter.wordpress.com/1858/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seroter.wordpress.com/1858/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1858&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seroter.wordpress.com/2011/12/15/my-streaminsight-course-for-pluralsight-is-now-available/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ef5fd2c721814f5491c1f6bfdadf4753?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">rseroter</media:title>
		</media:content>
	</item>
		<item>
		<title>First Look: Deploying .NET Web Apps to Cloud Foundry via Iron Foundry</title>
		<link>http://seroter.wordpress.com/2011/12/13/first-look-deploying-net-web-apps-to-cloud-foundry-via-iron-foundry/</link>
		<comments>http://seroter.wordpress.com/2011/12/13/first-look-deploying-net-web-apps-to-cloud-foundry-via-iron-foundry/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 10:49:57 +0000</pubDate>
		<dc:creator>Richard Seroter</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Cloud Foundry]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[WCF/WF]]></category>

		<guid isPermaLink="false">https://seroter.wordpress.com/?p=1846</guid>
		<description><![CDATA[It’s been a good week for .NET developers who like the cloud.  First, Microsoft makes a huge update to Windows Azure that improves everything from billing to support for lots of non-Microsoft platforms like memcached and Node.js. Second, there was a significant announcement today from Tier 3 regarding support for .NET in a Cloud Foundry [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1846&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It’s been a good week for .NET developers who like the cloud.  First, Microsoft <a href="http://blogs.msdn.com/b/windowsazure/archive/2011/12/12/improved-developer-experience-interoperability-and-scalability-on-windows-azure.aspx" target="_blank">makes a huge update to Windows Azure</a> that improves everything from billing to support for lots of non-Microsoft platforms like memcached and Node.js. Second, there was a<a href="http://blog.tier3.com/index.php/2011/12/iron-foundry-open-source-net-paas" target="_blank"> significant announcement</a> today from <a href="http://www.tier3.com/" target="_blank">Tier 3</a> regarding support for .NET in a Cloud Foundry environment.</p>
<p>I’ve written a bit about <a href="http://seroter.wordpress.com/2011/05/11/6-quick-steps-for-windows-net-folks-to-try-out-cloud-foundry/" target="_blank">Cloud Foundry in the past</a>, and have watched it become one of the most popular platforms for cloud developers.  While Cloud Foundry supports a diverse set of platforms like Java, Ruby and Node.js, .NET has been conspicuous absent from that list.  That’s where Tier 3 jumped in.  They’ve forked the Cloud Foundry offering and made a .NET version (called<a href="http://www.ironfoundry.org" target="_blank"> Iron Foundry</a>) that can run by an online hosted provider, or, <span style="text-decoration:underline;"><strong>in your own data center</strong></span>. Your own private, <strong>open source</strong> .NET PaaS.  That’s a big deal.</p>
<p>I’ve been working a bit with their team for the past few weeks, and if you’d like to read more from their technical team, check out<a href="http://www.infoq.com/news/2011/12/dotnet-cloudfoundry" target="_blank"> the article that I wrote for InfoQ.com today</a>.  Let’s jump in and try and deploy a very simple RESTful WCF service to Iron Foundry using the tools they’ve made available.</p>
<h2>Demo</h2>
<p>First off, I pulled the source code from their GitHub library.  After building that, I made sure that I could open up their standalone Cloud Foundry Explorer tool and log into my account. This tool also plugs into Visual Studio 2010, and I’ll show that soon [<strong>12/22 update: note that Iron Foundry's production URL has changed from the value used in the screenshot below</strong>].</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry01.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry01" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry01_thumb.png?w=450&#038;h=294" alt="2011.12.13ironfoundry01" width="450" height="294" border="0" /></a></p>
<p>It’s a nice little tool that shows me any apps I have running, and lets me interact with them.  But, I have no apps deployed here, so let’s change that!  How about we go with a very simple WCF contract that returns a customer object when the caller hits a specific URI.  Here’s the WCF contract:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:30fe7bee-f408-44c3-a5df-a727982ca537" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; pad-line-numbers: true;">
[ServiceContract]
    public interface ICustomer
    {
        [OperationContract]
        [WebGet(UriTemplate = &quot;/{id}&quot;)]
        Customer GetCustomer(string id);
    }

    [DataContract]
    public class Customer
    {
        [DataMember]
        public string Id { get; set; }
        [DataMember]
        public string FullName { get; set; }
        [DataMember]
        public string Country { get; set; }
        [DataMember]
        public DateTime DateRegistered { get; set; }
    }
</pre></p>
</div>
<p>The implementation of this service is extremely simple.  Based on the input ID, I return one of a few different customer records.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:1bc709b4-35d7-49b9-9c9d-3da58af18d61" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: cpp;">
public class CustomerService : ICustomer
    {
        public Customer GetCustomer(string id)
        {
            Customer c = new Customer();
            c.Id = id;

            switch (id)
            {
                case &quot;100&quot;:
                    c.FullName = &quot;Richard Seroter&quot;;
                    c.Country = &quot;USA&quot;;
                    c.DateRegistered = DateTime.Parse(&quot;2011-08-24&quot;);
                    break;
                case &quot;200&quot;:
                    c.FullName = &quot;Jared Wray&quot;;
                    c.Country = &quot;USA&quot;;
                    c.DateRegistered = DateTime.Parse(&quot;2011-06-05&quot;);
                    break;
                default:
                    c.FullName = &quot;Shantu Roy&quot;;
                    c.Country = &quot;USA&quot;;
                    c.DateRegistered = DateTime.Parse(&quot;2011-05-11&quot;);
                    break;
            }

            return c;
        }
</pre></p>
</div>
<p>My WCF service configuration is also pretty straightforward.  However, note that<strong> I do NOT specify a full service address</strong>. When I asked one of the Iron Foundry developers about this he said:</p>
<blockquote><p>When an application is deployed, the cloud controller picks a server out of our farm of servers to which to deploy the application. On that server, a random high port number is chosen and a dedicated web site and app pool is configured to use that port. The router service then uses that URL (http://server:49367) when requests come in to http://&lt;application&gt;.gofoundry.net</p></blockquote>
<p><pre class="brush: xml; html-script: false;">
&lt;configuration&gt;
&lt;system.web&gt;
&lt;compilation debug=&quot;true&quot; targetFramework=&quot;4.0&quot; /&gt;
&lt;/system.web&gt;
&lt;system.serviceModel&gt;
&lt;bindings&gt;
&lt;webHttpBinding&gt;
&lt;binding name=&quot;WebBinding&quot; /&gt;
&lt;/webHttpBinding&gt;
&lt;/bindings&gt;
&lt;services&gt;
&lt;service name=&quot;Seroter.IronFoundry.WcfRestServiceDemo.CustomerService&quot;&gt;
&lt;endpoint address=&quot;CustomerService&quot; behaviorConfiguration=&quot;RestBehavior&quot;
binding=&quot;webHttpBinding&quot; bindingConfiguration=&quot;WebBinding&quot; contract=&quot;Seroter.IronFoundry.WcfRestServiceDemo.ICustomer&quot; /&gt;
&lt;/service&gt;
&lt;/services&gt;
&lt;behaviors&gt;
&lt;endpointBehaviors&gt;
&lt;behavior name=&quot;RestBehavior&quot;&gt;
&lt;webHttp helpEnabled=&quot;true&quot; /&gt;
&lt;/behavior&gt;
&lt;/endpointBehaviors&gt;
&lt;serviceBehaviors&gt;
&lt;behavior name=&quot;&quot;&gt;
&lt;serviceMetadata httpGetEnabled=&quot;true&quot; /&gt;
&lt;serviceDebug includeExceptionDetailInFaults=&quot;true&quot; /&gt;
&lt;/behavior&gt;
&lt;/serviceBehaviors&gt;
&lt;/behaviors&gt;
&lt;serviceHostingEnvironment multipleSiteBindingsEnabled=&quot;true&quot; /&gt;
&lt;/system.serviceModel&gt;
&lt;system.webServer&gt;
&lt;modules runAllManagedModulesForAllRequests=&quot;true&quot;/&gt;
&lt;/system.webServer&gt;
&lt;connectionStrings&gt;&lt;/connectionStrings&gt;
&lt;/configuration&gt;
</pre></p>
<p>I’m not ready to deploy this application. While  I could use the standalone Cloud Foundry Explorer that I showed you before, or even the vmc command line, the easiest one is the Visual Studio plug in.  By right-clicking my project, I can choose <strong>Push Cloud Foundry Application</strong> which launches the Cloud Foundry Explorer.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry02.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry02" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry02_thumb.png?w=450&#038;h=265" alt="2011.12.13ironfoundry02" width="450" height="265" border="0" /></a></p>
<p>Now I can select my existing Iron Foundry configuration named <strong>Sample Server</strong> (which points to the Iron Foundry endpoint and includes my account credentials), select a name for my application, choose a URL, and pick both the memory size (64MB up to 2048MB) and application instance count [<strong>12/22 update: note that Iron Foundry's production URL has changed from the value used in the screenshot below]</strong>.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry03.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry03" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry03_thumb.png?w=450&#038;h=375" alt="2011.12.13ironfoundry03" width="450" height="375" border="0" /></a></p>
<p>The application is then pushed to the cloud. What’s awesome is that the application is <strong>instantly available</strong> after publishing.  No waits, no delays.  Want to see the app in action?  Based on the values I entered during deployment, you can hit the URL at <a href="http://serotersample6.gofoundry.net/CustomerService.svc/CustomerService/100" target="_blank">http://serotersample6.gofoundry.net/CustomerService.svc/CustomerService/100</a>. [<strong>12/22 update: note that Iron Foundry's production URL has changed, so the working URL above doesn't match the values I showed in the screenshots</strong>]</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry04.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry04" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry04_thumb.png?w=450&#038;h=143" alt="2011.12.13ironfoundry04" width="450" height="143" border="0" /></a></p>
<p>Sweet.  Now let’s check out some diagnostic info, shall we?  I can fire up the standalone Cloud Foundry Explorer and see my application running.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry05.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry05" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry05_thumb.png?w=450&#038;h=247" alt="2011.12.13ironfoundry05" width="450" height="247" border="0" /></a></p>
<p>What can I do now?  On the right side of the screen, I have options to change/add URLs that map to my service, increase my allocated memory, or modify the number of application instances.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry06.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry06" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry06_thumb.png?w=450&#038;h=185" alt="2011.12.13ironfoundry06" width="450" height="185" border="0" /></a></p>
<p>On the bottom left of the this screen, I can find out details of the instances that I’m running on.  Here, I’m on a single instance and my app has been running for 5 minutes.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry07.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry07" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry07_thumb.png?w=450&#038;h=148" alt="2011.12.13ironfoundry07" width="450" height="148" border="0" /></a></p>
<p>Finally,  I can provision application services associated with my web application.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry08.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry08" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry08_thumb.png?w=450&#038;h=389" alt="2011.12.13ironfoundry08" width="450" height="389" border="0" /></a></p>
<p>Let’s change my instance count.  I was blown away when I simply “upticked” the Instances value and <strong>instantly</strong> I saw another instance provisioned.  I don’t think Azure is anywhere near as fast.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry11.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry11" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry11_thumb.png?w=321&#038;h=307" alt="2011.12.13ironfoundry11" width="321" height="307" border="0" /></a></p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry12.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry12" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry12_thumb.png?w=450&#038;h=131" alt="2011.12.13ironfoundry12" width="450" height="131" border="0" /></a></p>
<p>What if I like using the vmc command line tool to administer my Iron Foundry application?  Let’s try that out. I went to the .NET version of the vmc tool that came with the Iron Foundry code download, and targeted the API just like you would in “regular” Cloud Foundry.[<strong>12/22 update: note that Iron Foundry's production URL has changed from the value used in the screenshot below</strong>].</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry09.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry09" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry09_thumb.png?w=450&#038;h=188" alt="2011.12.13ironfoundry09" width="450" height="188" border="0" /></a></p>
<p>It’s awesome (and I guess, expected) that all the vmc commands work the same and I can prove that by issuing the “vmc apps” command which should show me my running applications.</p>
<p><a href="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry10.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="2011.12.13ironfoundry10" src="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry10_thumb.png?w=450&#038;h=82" alt="2011.12.13ironfoundry10" width="450" height="82" border="0" /></a></p>
<p>Not everything was supported yet on my build, so if I want to increase the instance count or memory, I’d jump back to the Cloud Foundry Explorer tool.</p>
<h2>Summary</h2>
<p>What a great offering. Imagine deploying this within your company as a way to have a private PaaS. Or using it as a public PaaS and have the same deployment experience for .NET, Java, Ruby and Node applications.  I’m definitely going to troll through the source code since I know what a smart bunch build the “original” Cloud Foundry and I want to see how the cool underpinnings of that (internal pub/sub, cloud controller, router, etc) translated to .NET.</p>
<p>I encourage you to take a look.  I like Windows Azure, but more choice is a good thing and I congratulate the Tier 3 team on open sourcing their offering and doing such a cool service for the community.</p>
<br />Filed under: <a href='http://seroter.wordpress.com/category/net/'>.NET</a>, <a href='http://seroter.wordpress.com/category/cloud/'>Cloud</a>, <a href='http://seroter.wordpress.com/category/cloud-foundry/'>Cloud Foundry</a>, <a href='http://seroter.wordpress.com/category/soa/'>SOA</a>, <a href='http://seroter.wordpress.com/category/wcfwf/'>WCF/WF</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seroter.wordpress.com/1846/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seroter.wordpress.com/1846/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seroter.wordpress.com/1846/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seroter.wordpress.com/1846/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seroter.wordpress.com/1846/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seroter.wordpress.com/1846/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seroter.wordpress.com/1846/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seroter.wordpress.com/1846/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seroter.wordpress.com/1846/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seroter.wordpress.com/1846/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seroter.wordpress.com/1846/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seroter.wordpress.com/1846/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seroter.wordpress.com/1846/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seroter.wordpress.com/1846/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1846&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seroter.wordpress.com/2011/12/13/first-look-deploying-net-web-apps-to-cloud-foundry-via-iron-foundry/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ef5fd2c721814f5491c1f6bfdadf4753?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">rseroter</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry01_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry01</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry02_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry02</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry03_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry03</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry04_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry04</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry05_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry05</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry06_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry06</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry07_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry07</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry08_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry08</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry11_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry11</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry12_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry12</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry09_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry09</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/12/2011-12-13ironfoundry10_thumb.png" medium="image">
			<media:title type="html">2011.12.13ironfoundry10</media:title>
		</media:content>
	</item>
		<item>
		<title>Interview Series: Four Questions With &#8230; Clemens Vasters</title>
		<link>http://seroter.wordpress.com/2011/12/01/interview-series-four-questions-with-clemens-vasters/</link>
		<comments>http://seroter.wordpress.com/2011/12/01/interview-series-four-questions-with-clemens-vasters/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 09:39:16 +0000</pubDate>
		<dc:creator>Richard Seroter</dc:creator>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Four Questions]]></category>
		<category><![CDATA[General Architecture]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[Windows Azure]]></category>
		<category><![CDATA[Windows Azure AppFabric]]></category>

		<guid isPermaLink="false">https://seroter.wordpress.com/?p=1812</guid>
		<description><![CDATA[Greetings and welcome to the 36th interview in my monthly series of chat with thought leaders in connected technologies. This month we have the pleasure of talking to Clemens Vasters who is Principal Technical Lead on Microsoft’s Windows Azure AppFabric team, blogger, speaker, Tweeter, and all around interesting fellow.  He is probably best known for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1812&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Greetings and welcome to the <a href="http://seroter.wordpress.com/category/four-questions/" target="_blank">36th interview</a> in my monthly series of chat with thought leaders in connected technologies. This month we have the pleasure of talking to Clemens Vasters who is Principal Technical Lead on Microsoft’s Windows Azure AppFabric team, <a href="http://vasters.com/clemensv/" target="_blank">blogger</a>, speaker, <a href="https://twitter.com/#!/clemensv" target="_blank">Tweeter</a>, and all around interesting fellow.  He is probably best known for writing the blockbuster book, <a href="http://www.amazon.com/BizTalk-Server-2000-Beginners-Guide/dp/0072190116/ref=sr_1_1?s=books&amp;ie=UTF8&amp;qid=1322717215&amp;sr=1-1" target="_blank">BizTalk Server 2000: A Beginner’s Guide</a>. Just kidding.  He’s probably best known as a very public face of Microsoft’s Azure team and someone who is instrumental in shaping Microsoft’s cloud and integration platform.</p>
<p>Let’s see how he stands up to the rigor of Four Questions.</p>
<div style="border:black 1px solid;padding:4px 8px;">
<p><strong>Q: <strong>What principles of distributed systems do you think play an elevated role in cloud-driven software solutions? Where does &#8220;integrating with the cloud&#8221; introduce differences from &#8220;integrating within my data center&#8221;?</strong></strong></p>
<p><strong>A: </strong>I believe we need to first differentiate “the cloud” a bit to figure out what elevated concerns are. In a pure IaaS scenario where the customer is effectively renting VM space, the architectural differences between a self-contained  solution in the cloud and on-premises are commonly relatively small. That also explains why IaaS is doing pretty well right now – the workloads don’t have to change radically. That also means that if the app doesn’t scale in your own datacenter it also won’t scale in someone else’s; there’s no magic Pixie dust in the cloud. From an ops perspective, IaaS should be a seamless move if the customer is already running proper datacenter operations today. With that I mean that they are running their systems largely hands-off with nobody having to walk up to the physical box except for dealing with hardware failures.</p>
<p>The term “self-contained solution” that I mentioned earlier is key here since that’s clearly not always the case. We’ve been preaching EAI for quite a while now and not all workloads will move into cloud environments at once – there will always be a need to bridge between cloud-based workloads and workloads that remain on-premises or workloads that are simply location-bound because that’s where the action is – think of an ATM or a cashier’s register in a restaurant or a check-in terminal at an airport. All these are parts of a system and if you move the respective backend workloads into the cloud your ways of wiring it all together will change somewhat since you now have the public Internet between your assets and the backend. That’s a challenge, but also a tremendous opportunity and that’s what I work on here at Microsoft.</p>
<p>In PaaS scenarios that are explicitly taking advantage of cloud elasticity, availability, and reach &#8211; in which I include “bring your own PaaS” frameworks that are popping up here and there &#8211; the architectural differences are more pronounced. Some of these solutions deal with data or connections at very significant scale and that’s where you’re starting to hit the limits of quite a few enterprise infrastructure components. Large enterprises have some 100,000 employees (or more), which obviously first seems like a lot; looking deeper, an individual business solution in that enterprise is used by some fraction of that work-force, but the result is still a number that makes the eyes of salespeople shine. What’s easy to overlook is that that isn’t the interesting set of numbers for an enterprise that leverages IT as a competitive asset  – the more interesting one is how they can deeply engage with the 10+ million consumer customers they have. Once you’re building solutions for an audience of 10+ million people that you want to engage deeply, you’re starting to look differently at how you deal with data and whether you’re willing to hold that all in a single store or to subject records in that data store to a lock held by a transaction coordinator.  You also find that you can no longer take a comfy weekend to upgrade your systems – you run and you upgrade while you run and you don’t lose data while doing it. That’s quite a bit of a difference.</p>
<p><strong>Q: <strong>When building the Azure AppFabric Service Bus, what were some of the trickiest things to work out, from a technical perspective?</strong><strong> </strong></strong></p>
<p><strong>A: </strong>There are a few really tricky bits and those are common across many cloud solutions: How do I optimize the use of system resources so that I can run a given target workload on a minimal set of machines to drive down cost? How do I make the system so robust that it self-heals from intermittent error conditions such as a downstream dependency going down? How do I manage shared state in the system? These are the three key questions. The latter is the eternal classic in architecture and the one you hear most noise about. The whole SQL/NoSQL debate is about where and how to hold shared state. Do you partition, do you hold it in a single place, do you shred it across machines, do you flush to disk or keep in memory, what do you cache and for how long, etc, etc. We’re employing a mix of approaches since there’s no single answer across all use-cases. Sometimes you need a query processor right by the data, sometimes you can do without. Sometimes you must have a single authoritative place for a bit of data and sometimes it’s ok to have multiple and even somewhat stale copies.</p>
<p>I think what I learned most about while working on this here were the first two questions, though. Writing apps while being conscious about what it costs to run them is quite interesting and forces quite a bit of discipline. I/O code that isn’t fully asynchronous doesn’t pass code-review around here anymore. We made a cleanup pass right after shipping the first version of the service and subsequently dropped 33% of the VMs from each deployment with the next rollout while maintaining capacity. That gain was from eliminating all remaining cases of blocking I/O. The self-healing capabilities are probably the most interesting from an architectural perspective. I published a blog article about one of the patterns a while back [<a href="http://vasters.com/clemensv/2010/09/28/Cloud+Architecture+The+SchedulerAgentSupervisor+Pattern.aspx">here</a>]. The greatest insight here is that failures are just as much part of running the system as successes are and that there’s very little that your app cannot anticipate. If your backend database goes away you log that fact as an alert and probably prevent your system from hitting the database for a minute until the next retry, but your system stays up. Yes, you’ll fail transactions and you may fail (nicely) even back to the end-user, but you stay up. If you put a queue between the user and the database you can even contain that particular problem – albeit you then still need to be resilient against the queue not working.</p>
<p><strong>Q: <strong>The majority of documentation and evangelism of the AppFabric Service Bus has been targeted at developers and application architects. But for mature, risk-averse enterprises, there are other stakeholders like Operations and Information Security who have a big say in the introduction of a technology like this.  Can you give us a brief &#8220;Service Bus for Operations&#8221; and &#8220;Service Bus for Security Professionals&#8221; summary that addresses the salient points for those audiences?</strong><strong> </strong></strong></p>
<p><strong>A: </strong>The Service Bus is squarely targeted at developers and architects at this time; that’s mostly a function of where we are in the cycle of building out the capabilities. For now we’re an “implementation detail” of apps that want to bet on the technology more than something that an IT Professional would take into their hands and wire something up without writing code or at least craft some config that requires white-box knowledge of the app. I expect that to change quite a bit over time and I expect that you’ll see some of that showing up in the next 12 months. When building apps you need to expect our components to fail just like any other, especially because there’s also quite a bit of stuff that can go wrong on the way. You may have no connectivity to Service Bus, for instance. What the app needs to have in its operational guidance documents is how to interpret these failures, what failure threshold triggers an alert (it’s rarely “1), and where to go (call Microsoft support with this number and with this data) when the failures indicate something entirely unexpected.</p>
<p>From the security folks we see most concerns about us allowing connectivity into the datacenter with the Relay; for which we’re not doing anything that some other app couldn’t do, we’re just providing it as a capability to build on. If you allow outbound traffic out of a machine you are allowing responses to get back in. That traffic is scoped to the originating app holding the socket. If that app were to choose to leak out information it’d probably be overkill to use Service Bus – it’s much easier to do that by throwing documents on some obscure web site via HTTPS.  Service Bus traffic can be explicitly blocked and we use a dedicated TCP port range to make that simple and we also have headers on our HTTP tunneling traffic that are easy to spot and we won’t ever hide tunneling over HTTPS, so we designed this with such concerns in mind. If an enterprise wants to block Service Bus traffic completely that’s just a matter of telling the network edge systems.</p>
<p>However, what we’re seeing more of is excitement in IT departments that ‘get it’ and understand that Service Bus can act as an external DMZ for them. We have a number of customers who are pulling internal services to the public network edge using Service Bus, which turns out to be a lot easier than doing that in their own infrastructure, even with full IT support. What helps there is our integration with the Access Control service that provides a security gate at the edge even for services that haven’t been built for public consumption, at all.</p>
<p><strong>Q [stupid question]: <strong>I&#8217;m of the opinion that cold scrambled eggs, or cold mashed potatoes are terrible.  Don&#8217;t get me started on room-temperature french fries. Similarly, I really enjoy a crisp, cold salad and find warm salads unappealing.  What foods or drinks have to be a certain temperature for you to truly enjoy them?</strong><strong> </strong></strong></p>
<p><strong>A: </strong>I’m German. The only possible answer here is “beer”. There are some breweries here in the US that are trying to sell their terrible product by apparently successfully convincing consumers to drink their so called “beer” at a temperature that conveniently numbs down the consumer’s sense of taste first. It’s as super-cold as the Rockies and then also tastes like you’re licking a rock. In odd contrast with this, there are rumors about the structural lack of appropriate beer cooling on certain islands on the other side of the Atlantic&#8230;</p>
</div>
<p>Thanks Clemens for participating! Great perspectives.</p>
<br />Filed under: <a href='http://seroter.wordpress.com/category/cloud/'>Cloud</a>, <a href='http://seroter.wordpress.com/category/four-questions/'>Four Questions</a>, <a href='http://seroter.wordpress.com/category/general-architecture/'>General Architecture</a>, <a href='http://seroter.wordpress.com/category/soa/'>SOA</a>, <a href='http://seroter.wordpress.com/category/windows-azure/'>Windows Azure</a>, <a href='http://seroter.wordpress.com/category/windows-azure-appfabric/'>Windows Azure AppFabric</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seroter.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seroter.wordpress.com/1812/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seroter.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seroter.wordpress.com/1812/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seroter.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seroter.wordpress.com/1812/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seroter.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seroter.wordpress.com/1812/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seroter.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seroter.wordpress.com/1812/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seroter.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seroter.wordpress.com/1812/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seroter.wordpress.com/1812/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seroter.wordpress.com/1812/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1812&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seroter.wordpress.com/2011/12/01/interview-series-four-questions-with-clemens-vasters/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ef5fd2c721814f5491c1f6bfdadf4753?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">rseroter</media:title>
		</media:content>
	</item>
		<item>
		<title>Integration in the Cloud: Part 4 &#8211; Asynchronous Messaging Pattern</title>
		<link>http://seroter.wordpress.com/2011/11/15/integration-in-the-cloud-part-4-asynchronous-messaging-pattern/</link>
		<comments>http://seroter.wordpress.com/2011/11/15/integration-in-the-cloud-part-4-asynchronous-messaging-pattern/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 16:14:58 +0000</pubDate>
		<dc:creator>Richard Seroter</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Cloud Foundry]]></category>
		<category><![CDATA[General Architecture]]></category>
		<category><![CDATA[Salesforce.com]]></category>
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">https://seroter.wordpress.com/?p=1801</guid>
		<description><![CDATA[So far in this blog series we’ve been looking at how Enterprise Integration Patterns apply to cloud integration scenarios. We’ve seen that a Shared Database Pattern works well when you have common data (and schema) and multiple consumers who want consistent access.  The Remote Procedure Invocation Pattern is a good fit when one system desires [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1801&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So far in this blog series we’ve been looking at how Enterprise Integration Patterns apply to cloud integration scenarios. We’ve seen that a <a href="http://seroter.wordpress.com/2011/10/28/integration-in-the-cloud-part-2-shared-database-pattern/" target="_blank">Shared Database Pattern</a> works well when you have common data (and schema) and multiple consumers who want consistent access.  The <a href="http://seroter.wordpress.com/2011/11/01/integration-in-the-cloud-part-3-remote-procedure-invocation-pattern/" target="_blank">Remote Procedure Invocation Pattern</a> is a good fit when one system desires synchronous access to data and functions sitting in other systems. In this final post in the series, I’ll walk through the <strong>Asynchronous Messaging Pattern</strong> and specifically demonstrate how to share data between clouds using this pattern.</p>
<h3>What Is It?</h3>
<p>While the remote procedure pattern provides looser coupling than the shared database pattern, it is still a blocking call and not particularly scalable.  Architects and developers use an asynchronous messaging pattern when they want to share data in the most scalable and responsive way possible.  Think of sending an email.  Your email client doesn’t sit and wait until the recipient has received and read the email message.  That would be atrocious. Instead, our email server does a <a href="http://en.wikipedia.org/wiki/Multicast" target="_blank">multicast</a> to recipients allows our email client to carry on. This is somewhat similar to <a href="http://en.wikipedia.org/wiki/Publish/subscribe" target="_blank">publish/subscribe</a> where the publisher does not dictate which specific receiver will get the message.</p>
<p>So in theory, the sender of the message doesn’t need to know where the message will end up.  They also don’t need to know *when* a message is received or processed by another party.  This supports disconnected client scenarios where the subscriber is not online at the same time as the publisher.  It also supports the principle of replicable units where one receiver could be swapped out with no direct impact to the source of the message.  We see this pattern realized in Enterprise Service Bus or Integration Bus products (like BizTalk Server) which promote extreme loose coupling between systems.</p>
<h3>Challenges</h3>
<p>There are a few challenges when dealing with this pattern.</p>
<ul>
<li><strong>There is no real-time consistency</strong>. Because the message source asynchronously shares data that will be processed at the convenience of the receiver, there is a low likelihood that the systems involved are simultaneously consistent.  Instead, you end up with eventual consistency between the players in the messaging solution.</li>
<li><strong>Reliability / durability is required in some cases</strong>. Without a persistence layer, it is possible to lose data.  Unlike the remote procedure invocation pattern (where exceptions are thrown by the target and both caught and handled by the caller), problems in transmission or target processing do not flow back to the publisher.  What happens if the recipient of a message is offline?  What if the recipient is under heavy load and rejecting new messages? A durable component in the messaging tier can protect against such cases by doing <a href="http://en.wikipedia.org/wiki/Store_and_forward" target="_blank">store-and-forward</a> type implementation that doesn’t remove the message from the durable store until it has been successfully consumed.</li>
<li><strong>A router may be useful when transmitting messages.</strong> Instead of, or in addition to a durable store, a routing component can help manage the central subscriptions for pub/sub transmissions, help with protocol bridging, data transformation and workflow (e.g. something like BizTalk Server). This may not be needed in distributed ESB solutions where the receiver is responsible for most of that.</li>
<li><strong>There is limited support for this pattern in packaged software products</strong>.  I’ve seen few commercial products that expose asynchronous inbound channels, and even fewer that have easy-to-configure ways to publish outbound events asynchronously.  It’s not that difficult to put adapters in front of these systems, or mimic asynchronous publication by polling a data tier, but it’s not the same.</li>
</ul>
<h3>Cloud Considerations</h3>
<p>What are things to consider when doing this pattern in a cloud scenario?</p>
<ul>
<li><strong>To do this between cloud and on-premises solutions, this requires creativity. </strong>I showed in <a href="http://seroter.wordpress.com/2011/11/01/integration-in-the-cloud-part-3-remote-procedure-invocation-pattern/" target="_blank">the previous post</a> how one can use Windows Azure AppFabric to expose on-premises endpoints to cloud applications. If we need to push data on-premises, and Azure AppFabric isn’t an option, then you’re looking at doing a VPN or internet-facing proxy service. Or, you could rely on aggressive polling of a shared queue (as I’ll show below).</li>
<li><strong>Cloud provider limits and architecture will influence solution design</strong>. Some vendors, such as Salesforce.com, limit the frequency and amount of polling that it will do. This impacts the ability to poll a durable store used between cloud applications. The distributed nature of cloud services. and embrace of the eventual consistency model, can change how one retrieves data.  For example, Amazon’s Simple Queue Service may not be first-in-first out, and <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/IntroductionArticle.html#SQSConcepts" target="_blank">uses a sampling algorithm</a> that COULD result in a query not returning all the messages in the logical queue.</li>
</ul>
<h3>Solution Demonstration</h3>
<p>Let’s say that the fictitious Seroter Corporation has a series of public websites and wants a consistent way to push customer inquiries from the websites to back end systems that process these inquiries.  Instead of pushing these inquiries directly into one or many CRM systems, or doing the low-tech email option, we’d rather <strong>put all the messages into a queue and let each interested party pull the ones they want</strong>.  Since these websites are cloud-hosted, we don’t want to explicitly push these messages into the internal network, but rather, asynchronously publish and poll messages from a shared queue hosted by <a href="http://aws.amazon.com/sqs/" target="_blank">Amazon Simple Queue Service (SQS)</a>. The polling applications could either be another cloud system (CRM system Salesforce.com) or an on-premises system, as shown below.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int01.png"><img style="display:inline;border-width:0;" title="2011.11.14int01" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int01_thumb.png?w=450&#038;h=385" alt="2011.11.14int01" width="450" height="385" border="0" /></a></p>
<p>So I’ll have a web page built using Ruby and hosted in Cloud Foundry, a SQS queue that holds inquiries submitted from that site, and both an on-premises .NET application and a SaaS Salesforce.com application that can poll that queue for messages.</p>
<p>Setting up a queue in SQS is so easy now, that I won’t even make it a sub-section in this post.  The AWS team recently added SQS operations to their Management Console, and they’ve made it very simple to create, delete, secure and monitor queues. I created a new queue named Seroter_CustomerInquiries.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int02.png"><img style="display:inline;border-width:0;" title="2011.11.14int02" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int02_thumb.png?w=450&#038;h=158" alt="2011.11.14int02" width="450" height="158" border="0" /></a></p>
<h4><strong><span style="color:#000080;">Sending Messages from Cloud Foundry to Amazon Simple Queue Service</span></strong></h4>
<p>In my Ruby (Sinatra) application, I have a page where a user can ask a question.  When they click the submit button, I go into the following routine which builds up the SQS message (similar to the SimpleDB message <a href="http://seroter.wordpress.com/2011/10/28/integration-in-the-cloud-part-2-shared-database-pattern/" target="_blank">from my previous post</a>) and posts a message to the queue.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:f2b04a23-d9eb-4459-b423-6a8ea6768137" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: ruby; pad-line-numbers: true;">
post '/submitted/:uid' do	# method call, on submit of the request path, do the following

   #--get user details from the URL string
	@userid = params[:uid]
	@message = CGI.escape(params[:message])
    #-- build message that will be sent to the queue
	@fmessage = @userid + &quot;-&quot; + @message.gsub(&quot;+&quot;, &quot;%20&quot;)

	#-- define timestamp variable and format
	@timestamp = Time.now
	@timestamp = @timestamp.strftime(&quot;%Y-%m-%dT%H:%M:%SZ&quot;)
	@ftimestamp = CGI.escape(@timestamp)

	#-- create signing string
	@stringtosign = &quot;GET\n&quot; + &quot;queue.amazonaws.com\n&quot; + &quot;/084598340988/Seroter_CustomerInquiries\n&quot; + &quot;AWSAccessKeyId=ACCESS_KEY&quot; + &quot;&amp;Action=SendMessage&quot; + &quot;&amp;MessageBody=&quot; + @fmessage + &quot;&amp;SignatureMethod=HmacSHA1&quot; + &quot;&amp;SignatureVersion=2&quot; + &quot;&amp;Timestamp=&quot; + @ftimestamp + &quot;&amp;Version=2009-02-01&quot;

	#-- create hashed signature
	@esignature = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1',@@awskey, @stringtosign)).chomp)

	#-- create AWS SQS query URL
	@sqsurl = &quot;https://queue.amazonaws.com/084598340988/Seroter_CustomerInquiries?Action=SendMessage&quot; + &quot;&amp;MessageBody=&quot; + @fmessage + &quot;&amp;Version=2009-02-01&quot; + &quot;&amp;Timestamp=&quot; + @ftimestamp + &quot;&amp;Signature=&quot; + @esignature + &quot;&amp;SignatureVersion=2&quot; + &quot;&amp;SignatureMethod=HmacSHA1&quot; + &quot;&amp;AWSAccessKeyId=ACCESS_KEY&quot;

	#-- load XML returned from query
	@doc = Nokogiri::XML(open(@sqsurl))

   #-- build result message which is formatted string of the inquiry text
	@resultmsg = @fmessage.gsub(&quot;%20&quot;, &quot;&amp;nbsp;&quot;)

	haml :SubmitResult
end
</pre></p>
</div>
<p>The hard part when building these demos was getting my signature string and hashing exactly right, so hopefully this helps someone out.</p>
<p>After building and deploying the Ruby site to Cloud Foundry, I could see my page for inquiry submission.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int03.png"><img style="display:inline;border-width:0;" title="2011.11.14int03" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int03_thumb.png?w=450&#038;h=331" alt="2011.11.14int03" width="450" height="331" border="0" /></a></p>
<p>When the user hits the “Send Inquiry” button, the function above is called and assuming that I published successfully to the queue, I see the acknowledgement page.  Since this is an asynchronous communication, my web app only has to wait for publication to the queue, not invoking a function in a CRM system.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int04.png"><img style="display:inline;border-width:0;" title="2011.11.14int04" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int04_thumb.png?w=419&#038;h=260" alt="2011.11.14int04" width="419" height="260" border="0" /></a></p>
<p>To confirm that everything worked, I viewed my SQS queue and can clearly see that I have a single message waiting in the queue.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int05.png"><img style="display:inline;border-width:0;" title="2011.11.14int05" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int05_thumb.png?w=450&#038;h=166" alt="2011.11.14int05" width="450" height="166" border="0" /></a></p>
<h4><strong><span style="color:#000080;">.NET Application Pulling Messages from an SQS Queue</span></strong></h4>
<p>With our message sitting safely in the queue, now we can go grab it.  The first consuming application is an on-premises .NET app.  In this very feature-rich application, I poll the queue and pull down any messages found.  When working with queues, you often have two distinct operations: read and delete (“peek” is also nice to have). I can read messages from a queue, but unless I delete them, they become available (after a timeout) to another consumer.  For this scenario, we’d realistically want to read all the messages, and ONLY process and delete the ones targeted for our CRM app.  Any others, we simply don’t delete, and they go back to waiting in the queue. I haven’t done that, for simplicity sake, but keep this in mind for actual implementations.</p>
<p>In the example code below, I’m being a bit lame by only expecting a single message. In reality, when polling, you’d loop through each returned message, save its Handle value (which is required when calling the Delete operation) and do something with the message.  In my case, I only have one message, so I explicitly grab the “Body” and “Handle” values.  The code shows the “retrieve messages” button click operation which in turn calls “receive” operation and “delete” operation.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:723be056-48f8-4724-8454-6865ed36c7fa" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; highlight: [24,26,44,47,48,96,98,114];">
private void RetrieveButton_Click(object sender, EventArgs e)
        {
            lbQueueMsgs.Items.Clear();
            lblStatus.Text = &quot;Status:&quot;;

            string handle = ReceiveFromQueue();
            if(handle!=null)
                DeleteFromQueue(handle);

        }

private string ReceiveFromQueue()
        {
            //timestamp formatting for AWS
            string timestamp = Uri.EscapeUriString(string.Format(&quot;{0:s}&quot;, DateTime.UtcNow));
            timestamp = DateTime.Now.ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;);
            timestamp = HttpUtility.UrlEncode(timestamp).Replace(&quot;%3a&quot;, &quot;%3A&quot;);

            //string for signing
            string stringToConvert = &quot;GET\n&quot; +
            &quot;queue.amazonaws.com\n&quot; +
            &quot;/084598340988/Seroter_CustomerInquiries\n&quot; +
            &quot;AWSAccessKeyId=ACCESS_KEY&quot; +
            &quot;&amp;Action=ReceiveMessage&quot; +
            &quot;&amp;AttributeName=All&quot; +
            &quot;&amp;MaxNumberOfMessages=5&quot; +
            &quot;&amp;SignatureMethod=HmacSHA1&quot; +
            &quot;&amp;SignatureVersion=2&quot; +
            &quot;&amp;Timestamp=&quot; + timestamp +
            &quot;&amp;Version=2009-02-01&quot; +
            &quot;&amp;VisibilityTimeout=15&quot;;

            //hash the signature string
			  string awsPrivateKey = &quot;PRIVATE KEY&quot;;
            Encoding ae = new UTF8Encoding();
            HMACSHA1 signature = new HMACSHA1();
            signature.Key = ae.GetBytes(awsPrivateKey);
            byte[] bytes = ae.GetBytes(stringToConvert);
            byte[] moreBytes = signature.ComputeHash(bytes);
            string encodedCanonical = Convert.ToBase64String(moreBytes);
            string urlEncodedCanonical = HttpUtility.UrlEncode(encodedCanonical).Replace(&quot;%3d&quot;, &quot;%3D&quot;);

             //build up request string (URL)
            string sqsUrl = &quot;https://queue.amazonaws.com/084598340988/Seroter_CustomerInquiries?Action=ReceiveMessage&quot; +
            &quot;&amp;Version=2009-02-01&quot; +
            &quot;&amp;AttributeName=All&quot; +
            &quot;&amp;MaxNumberOfMessages=5&quot; +
            &quot;&amp;VisibilityTimeout=15&quot; +
            &quot;&amp;Timestamp=&quot; + timestamp +
            &quot;&amp;Signature=&quot; + urlEncodedCanonical +
            &quot;&amp;SignatureVersion=2&quot; +
            &quot;&amp;SignatureMethod=HmacSHA1&quot; +
            &quot;&amp;AWSAccessKeyId=ACCESS_KEY&quot;;

            //make web request to SQS using the URL we just built
            HttpWebRequest req = WebRequest.Create(sqsUrl) as HttpWebRequest;
            XmlDocument doc = new XmlDocument();
            using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(resp.GetResponseStream());
                string responseXml = reader.ReadToEnd();
                doc.LoadXml(responseXml);
            }

			 //do bad xpath and grab the body and handle
            XmlNode handle = doc.SelectSingleNode(&quot;//*[local-name()='ReceiptHandle']&quot;);
            XmlNode body = doc.SelectSingleNode(&quot;//*[local-name()='Body']&quot;);

            //if empty then nothing there; if not, then add to listbox on screen
            if (body != null)
            {
                //write result
                lbQueueMsgs.Items.Add(body.InnerText);
                lblStatus.Text = &quot;Status: Message read from queue&quot;;
                //return handle to calling function so that we can pass it to &quot;Delete&quot; operation
                return handle.InnerText;
            }
            else
            {
                MessageBox.Show(&quot;Queue empty&quot;);
                return null;
            }
        }

private void DeleteItem(string itemId)
        {
            //timestamp formatting for AWS
            string timestamp = Uri.EscapeUriString(string.Format(&quot;{0:s}&quot;, DateTime.UtcNow));
            timestamp = DateTime.Now.ToUniversalTime().ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffZ&quot;);
            timestamp = HttpUtility.UrlEncode(timestamp).Replace(&quot;%3a&quot;, &quot;%3A&quot;);

            string stringToConvert = &quot;GET\n&quot; +
            &quot;sdb.amazonaws.com\n&quot; +
            &quot;/\n&quot; +
            &quot;AWSAccessKeyId=ACCESS_KEY&quot; +
            &quot;&amp;Action=DeleteAttributes&quot; +
            &quot;&amp;DomainName=SeroterInteractions&quot; +
            &quot;&amp;ItemName=&quot; + itemId +
            &quot;&amp;SignatureMethod=HmacSHA1&quot; +
            &quot;&amp;SignatureVersion=2&quot; +
            &quot;&amp;Timestamp=&quot; + timestamp +
            &quot;&amp;Version=2009-04-15&quot;;

            string awsPrivateKey = &quot;PRIVATE KEY&quot;;
            Encoding ae = new UTF8Encoding();
            HMACSHA1 signature = new HMACSHA1();
            signature.Key = ae.GetBytes(awsPrivateKey);
            byte[] bytes = ae.GetBytes(stringToConvert);
            byte[] moreBytes = signature.ComputeHash(bytes);
            string encodedCanonical = Convert.ToBase64String(moreBytes);
            string urlEncodedCanonical = HttpUtility.UrlEncode(encodedCanonical).Replace(&quot;%3d&quot;, &quot;%3D&quot;);

            //build up request string (URL)
            string simpleDbUrl = &quot;https://sdb.amazonaws.com/?Action=DeleteAttributes&quot; +
            &quot;&amp;DomainName=SeroterInteractions&quot; +
            &quot;&amp;ItemName=&quot; + itemId +
            &quot;&amp;Version=2009-04-15&quot; +
            &quot;&amp;Timestamp=&quot; + timestamp +
            &quot;&amp;Signature=&quot; + urlEncodedCanonical +
            &quot;&amp;SignatureVersion=2&quot; +
            &quot;&amp;SignatureMethod=HmacSHA1&quot; +
            &quot;&amp;AWSAccessKeyId=ACCESS_KEY&quot;;

            HttpWebRequest req = WebRequest.Create(simpleDbUrl) as HttpWebRequest;

            using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(resp.GetResponseStream());

                string responseXml = reader.ReadToEnd();
            }
        }
</pre></p>
</div>
<p>When the application runs and pulls the message that I sent to the queue earlier, it looks like this.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int06.png"><img style="display:inline;border-width:0;" title="2011.11.14int06" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int06_thumb.png?w=403&#038;h=314" alt="2011.11.14int06" width="403" height="314" border="0" /></a></p>
<p>Nothing too exciting on the user interface, but we’ve just seen the magic that’s happening underneath. After running this (which included reading and deleting the message), the SQS queue is predictably empty.</p>
<h4><strong><span style="color:#000080;">Force.com Application Pulling from an SQS Queue</span></strong></h4>
<p>I went ahead and sent another message from my Cloud Foundry app into the queue.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int07.png"><img style="display:inline;border-width:0;" title="2011.11.14int07" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int07_thumb.png?w=372&#038;h=232" alt="2011.11.14int07" width="372" height="232" border="0" /></a></p>
<p>This time, I want my cloud CRM users on Salesforce.com to pull these new inquiries and process them.  I’d like to automatically convert the inquiries to CRM Cases in the system.  A custom class in a Force.com application can be <a href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm" target="_blank">scheduled to execute</a> every interval. To account for that (as the solution below supports both on-demand and scheduled retrieval from the queue), I’ve added a couple things to the code.  Specifically, notice that my “case lookup” class implements the Schedulable interface (which allows it be scheduled through the Force.com administrative tooling) and my “queue lookup” function uses the <a href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_future.htm" target="_blank">@future annotation</a> (which allows asynchronous invocation).</p>
<p>Much like the .NET application above, you’ll find operations below that retrieve content from the queue and then delete the messages it finds.  The solution differs from the one above in that it DOES handle multiple messages (not that it loops through retrieved results and calls “delete” for each) and also creates a Salesforce.com “case” for each result.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:ca7e57f9-d144-48e6-aa0b-ad9d08129750" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
//implement Schedulable to support scheduling
global class doCaseLookup implements Schedulable
{
	//required operation for Schedulable interfaces
    global void execute(SchedulableContext ctx)
    {
        QueueLookup();
    }

    @future(callout=true)
    public static void QueueLookup()
    {
	  //create HTTP objects and queue namespace
     Http httpProxy = new Http();
     HttpRequest sqsReq = new HttpRequest();
     String qns = 'http://queue.amazonaws.com/doc/2009-02-01/';

     //monkey with date format for SQS query
     Datetime currentTime = System.now();
     String formattedTime = currentTime.formatGmt('yyyy-MM-dd')+'T'+ currentTime.formatGmt('HH:mm:ss')+'.'+ currentTime.formatGmt('SSS')+'Z';
     formattedTime = EncodingUtil.urlEncode(formattedTime, 'UTF-8');

	  //build signing string
     String stringToSign = 'GET\nqueue.amazonaws.com\n/084598340988/Seroter_CustomerInquiries\nAWSAccessKeyId=ACCESS_KEY&amp;' +
			'Action=ReceiveMessage&amp;AttributeName=All&amp;MaxNumberOfMessages=5&amp;SignatureMethod=HmacSHA1&amp;SignatureVersion=2&amp;Timestamp=' +
			formattedTime + '&amp;Version=2009-02-01&amp;VisibilityTimeout=15';
     String algorithmName = 'HMacSHA1';
     Blob mac = Crypto.generateMac(algorithmName, Blob.valueOf(stringToSign),Blob.valueOf(PRIVATE_KEY));
     String macUrl = EncodingUtil.urlEncode(EncodingUtil.base64Encode(mac), 'UTF-8');

	  //build SQS URL that retrieves our messages
     String queueUrl = 'https://queue.amazonaws.com/084598340988/Seroter_CustomerInquiries?Action=ReceiveMessage&amp;' +
			'Version=2009-02-01&amp;AttributeName=All&amp;MaxNumberOfMessages=5&amp;VisibilityTimeout=15&amp;Timestamp=' +
			formattedTime + '&amp;Signature=' + macUrl + '&amp;SignatureVersion=2&amp;SignatureMethod=HmacSHA1&amp;AWSAccessKeyId=ACCESS_KEY';

     sqsReq.setEndpoint(queueUrl);
     sqsReq.setMethod('GET');

     //invoke endpoint
     HttpResponse sqsResponse = httpProxy.send(sqsReq);

     Dom.Document responseDoc = sqsResponse.getBodyDocument();
     Dom.XMLNode receiveResponse = responseDoc.getRootElement();
     //receivemessageresult node which holds the responses
     Dom.XMLNode receiveResult = receiveResponse.getChildElements()[0];

     //for each Message node
     for(Dom.XMLNode itemNode: receiveResult.getChildElements())
     {
        String handle= itemNode.getChildElement('ReceiptHandle', qns).getText();
        String body = itemNode.getChildElement('Body', qns).getText();

        //pull out customer ID
        Integer indexSpot = body.indexOf('-');
        String customerId = '';
        if(indexSpot &gt; 0)
        {
           customerId = body.substring(0, indexSpot);
        }

        //delete this message
        DeleteQueueMessage(handle);

	     //create a new case
        Case c = new Case();
        c.Status = 'New';
        c.Origin = 'Web';
        c.Subject = 'Web request: ' + body;
        c.Description = body;

		 //insert the case record into the system
        insert c;
     }
  }

  static void DeleteQueueMessage(string handle)
  {
	 //create HTTP objects
     Http httpProxy = new Http();
     HttpRequest sqsReq = new HttpRequest();

     //encode handle value associated with queue message
     String encodedHandle = EncodingUtil.urlEncode(handle, 'UTF-8');

	 //format the date
     Datetime currentTime = System.now();
     String formattedTime = currentTime.formatGmt('yyyy-MM-dd')+'T'+ currentTime.formatGmt('HH:mm:ss')+'.'+ currentTime.formatGmt('SSS')+'Z';
     formattedTime = EncodingUtil.urlEncode(formattedTime, 'UTF-8');

		//create signing string
     String stringToSign = 'GET\nqueue.amazonaws.com\n/084598340988/Seroter_CustomerInquiries\nAWSAccessKeyId=ACCESS_KEY&amp;' +
					'Action=DeleteMessage&amp;ReceiptHandle=' + encodedHandle + '&amp;SignatureMethod=HmacSHA1&amp;SignatureVersion=2&amp;Timestamp=' +
					formattedTime + '&amp;Version=2009-02-01';
     String algorithmName = 'HMacSHA1';
     Blob mac = Crypto.generateMac(algorithmName, Blob.valueOf(stringToSign),Blob.valueOf(PRIVATE_KEY));
     String macUrl = EncodingUtil.urlEncode(EncodingUtil.base64Encode(mac), 'UTF-8');

	  //create URL string for deleting a mesage
     String queueUrl = 'https://queue.amazonaws.com/084598340988/Seroter_CustomerInquiries?Action=DeleteMessage&amp;' +
					'Version=2009-02-01&amp;ReceiptHandle=' + encodedHandle + '&amp;Timestamp=' + formattedTime + '&amp;Signature=' +
					macUrl + '&amp;SignatureVersion=2&amp;SignatureMethod=HmacSHA1&amp;AWSAccessKeyId=ACCESS_KEY';

     sqsReq.setEndpoint(queueUrl);
     sqsReq.setMethod('GET');

	  //invoke endpoint
     HttpResponse sqsResponse = httpProxy.send(sqsReq);

     Dom.Document responseDoc = sqsResponse.getBodyDocument();
  }
}
</pre></p>
</div>
<p>When I view my custom APEX page which calls this function, I can see the button to query this queue.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int08.png"><img style="display:inline;border-width:0;" title="2011.11.14int08" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int08_thumb.png?w=412&#038;h=359" alt="2011.11.14int08" width="412" height="359" border="0" /></a></p>
<p>When I click the button, our function retrieves the message from the queue, deletes that message, and creates a Salesforce.com case.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int09.png"><img style="display:inline;border-width:0;" title="2011.11.14int09" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int09_thumb.png?w=450&#038;h=288" alt="2011.11.14int09" width="450" height="288" border="0" /></a></p>
<p>Cool!  This still required me to actively click a button, but we can also make this function run every hour.  In the Salesforce.com configuration screens, we have the option to view Scheduled Jobs.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int10.png"><img style="display:inline;border-width:0;" title="2011.11.14int10" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int10_thumb.png?w=208&#038;h=289" alt="2011.11.14int10" width="208" height="289" border="0" /></a></p>
<p>To actually create the job itself, I had created an Apex class which schedules the job.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:4ad78b9e-185c-465e-b8da-a77567c1f869" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
global class CaseLookupJobScheduler
{
    global void CaseLookupJobScheduler() {}

    public static void start()
    {
 		// takes in seconds, minutes, hours, day of month, month and day of week
		//the statement below tries to schedule every 5 min, but SFDC only allows hourly
        System.schedule('Case Queue Lookup', '0 5 1-23 * * ?', new doCaseLookup());
    }
}
</pre></p>
</div>
<p>Note that I use the <a href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_system.htm#using_schedule" target="_blank">System.schedule</a> operation. While my statement above says to schedules the doCaseLookup function to run every 5 minutes, in reality, it won’t.  Salesforce.com restricts these jobs from running too frequently and keeps jobs from running more than once per hour. One could technically game the system by using some of the ten allowable polling jobs to set of a series of jobs that start at different times of the hour. I’m not worrying about that here. To invoke this function and schedule the job, I first went to the <strong>System Log</strong> menu.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int12.png"><img style="display:inline;border-width:0;" title="2011.11.14int12" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int12_thumb.png?w=170&#038;h=134" alt="2011.11.14int12" width="170" height="134" border="0" /></a></p>
<p>From here, I can execute Apex code.  So, I can call my start() function, which should schedule the job.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int13.png"><img style="display:inline;border-width:0;" title="2011.11.14int13" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int13_thumb.png?w=450&#038;h=283" alt="2011.11.14int13" width="450" height="283" border="0" /></a></p>
<p>Now, if I view the <strong>Scheduled Jobs</strong> view from the Setup screens, I can see that my job is scheduled.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-11-14int14.png"><img style="display:inline;border-width:0;" title="2011.11.14int14" src="http://seroter.files.wordpress.com/2011/11/2011-11-14int14_thumb.png?w=450&#038;h=189" alt="2011.11.14int14" width="450" height="189" border="0" /></a></p>
<p>This job is now scheduled to run every hour.  This means that each hour, the queue is polled and any found messages are added to Salesforce.com as cases.  You could use a mix of both solutions and manually poll if you want to (through a button) but allow true asynchronous processing on all ends.</p>
<h3>Summary</h3>
<p>Asynchronous messaging is a great way to build scalable, loosely coupled systems. A durable intermediary helps provide assurances of message delivery, but this patterns works without it as well.  The demonstrations in this post shows how two cloud solutions can asynchronously exchange data through the use of a shared queue that sits between them.  The publisher to the queue has no idea who will retrieve the message and the retrievers have no direct connection to those who publish messages.  This makes for a very maintainable solution.</p>
<p>My goal with these posts was to demonstrate that classic Integration patterns work fine in cloudy environments. I think it’s important to not throw out existing patterns just because new technologies are introduced. I hope you enjoyed this series.</p>
<br />Filed under: <a href='http://seroter.wordpress.com/category/net/'>.NET</a>, <a href='http://seroter.wordpress.com/category/aws/'>AWS</a>, <a href='http://seroter.wordpress.com/category/cloud/'>Cloud</a>, <a href='http://seroter.wordpress.com/category/cloud-foundry/'>Cloud Foundry</a>, <a href='http://seroter.wordpress.com/category/general-architecture/'>General Architecture</a>, <a href='http://seroter.wordpress.com/category/salesforce-com/'>Salesforce.com</a>, <a href='http://seroter.wordpress.com/category/soa/'>SOA</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seroter.wordpress.com/1801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seroter.wordpress.com/1801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seroter.wordpress.com/1801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seroter.wordpress.com/1801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seroter.wordpress.com/1801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seroter.wordpress.com/1801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seroter.wordpress.com/1801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seroter.wordpress.com/1801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seroter.wordpress.com/1801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seroter.wordpress.com/1801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seroter.wordpress.com/1801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seroter.wordpress.com/1801/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seroter.wordpress.com/1801/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seroter.wordpress.com/1801/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1801&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seroter.wordpress.com/2011/11/15/integration-in-the-cloud-part-4-asynchronous-messaging-pattern/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ef5fd2c721814f5491c1f6bfdadf4753?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">rseroter</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int01_thumb.png" medium="image">
			<media:title type="html">2011.11.14int01</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int02_thumb.png" medium="image">
			<media:title type="html">2011.11.14int02</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int03_thumb.png" medium="image">
			<media:title type="html">2011.11.14int03</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int04_thumb.png" medium="image">
			<media:title type="html">2011.11.14int04</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int05_thumb.png" medium="image">
			<media:title type="html">2011.11.14int05</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int06_thumb.png" medium="image">
			<media:title type="html">2011.11.14int06</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int07_thumb.png" medium="image">
			<media:title type="html">2011.11.14int07</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int08_thumb.png" medium="image">
			<media:title type="html">2011.11.14int08</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int09_thumb.png" medium="image">
			<media:title type="html">2011.11.14int09</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int10_thumb.png" medium="image">
			<media:title type="html">2011.11.14int10</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int12_thumb.png" medium="image">
			<media:title type="html">2011.11.14int12</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int13_thumb.png" medium="image">
			<media:title type="html">2011.11.14int13</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-11-14int14_thumb.png" medium="image">
			<media:title type="html">2011.11.14int14</media:title>
		</media:content>
	</item>
		<item>
		<title>Integration in the Cloud: Part 3 &#8211; Remote Procedure Invocation Pattern</title>
		<link>http://seroter.wordpress.com/2011/11/01/integration-in-the-cloud-part-3-remote-procedure-invocation-pattern/</link>
		<comments>http://seroter.wordpress.com/2011/11/01/integration-in-the-cloud-part-3-remote-procedure-invocation-pattern/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 17:17:16 +0000</pubDate>
		<dc:creator>Richard Seroter</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Salesforce.com]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[WCF/WF]]></category>
		<category><![CDATA[Windows Azure AppFabric]]></category>

		<guid isPermaLink="false">https://seroter.wordpress.com/?p=1767</guid>
		<description><![CDATA[This post continues a series where I revisit the classic Enterprise Integration Patterns with a cloud twist. So far, I’ve introduced the series and looked at the Shared Database pattern. In this post, we’ll look the second pattern: remote procedure invocation. What Is It? One uses this remote procedure call (RPC) pattern when they have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1767&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post continues a series where I revisit the classic Enterprise Integration Patterns with a cloud twist. So far, I’ve <a href="http://seroter.wordpress.com/2011/10/28/integration-in-the-cloud-part-1-introduction/" target="_blank">introduced the series</a> and looked at the <a href="http://seroter.wordpress.com/2011/10/28/integration-in-the-cloud-part-2-shared-database-pattern/" target="_blank">Shared Database pattern</a>. In this post, we’ll look the second pattern: <strong>remote procedure invocation.</strong></p>
<h3>What Is It?</h3>
<p>One uses this remote procedure call (RPC) pattern when they have multiple, independent applications and want to share data or orchestrate cross-application processes. Unlike ETL scenarios where you move data between applications at defined intervals, or the shared database pattern where everyone accesses the same source data, the RPC pattern accesses data/process where it resides. Data typically stays with the source, and the consumer interacts with the other system through defined (service) contracts.</p>
<p>You often see Service Oriented Architecture (SOA) solutions built around the pattern.  That is, exposing reusable, interoperable, abstract interfaces for encapsulated services that interact with one or many systems.  This is a very familiar pattern for developers and good for mashup pages/services or any application that needs to know something (or do something) before it can proceed. You often do not need guaranteed delivery for these services since the caller is notified of any exceptions from the service and can simply retry the invocation.</p>
<h3>Challenges</h3>
<p>There are a few challenges when leveraging this pattern.</p>
<ul>
<li><strong>There is still some coupling involved.</strong> While a well-built service exposes an abstract interface that decouples the caller from the service’s underlying implementation, the caller is still bound the service exposed by the system. Changes to that system or unavailability of that system will affect the caller.</li>
<li><strong>Distinct service and capability offerings by each service</strong>. Unlike the shared database pattern where everyone agrees on a data schema and central repository, a RPC model leverages many services that reside all across the organization (or internet). One service may want certificate authentication, another uses Kerberos, and another does some weird token-based security. One service may support WS-Attachment and another may not.  Transactions may or may not be supported between services. In an RPC world, you are at the mercy of each service provider’s capabilities and design.</li>
<li><strong>RPC is a blocking call.</strong> When you call a service that sends a response, you pretty much have to sit around and wait until the response comes back. A caller can design around this a bit using AJAX on a web front end, or using a callback pattern in the middleware tier, but at root, you have a synchronous operation that holds a thread while waiting for a response.</li>
<li><strong>Queried data may be transient.</strong> If an application calls a service, gets some data, and shows it to a user, that data MAY not be persisted in the calling application. It’s cleaner that way, but, this prevents you from using the data in reports or workflows.  So, you simply have to decide early on if your calls to external services should result in persisted data (that must then either by synchronized or checked on future calls) or transient data.</li>
<li><strong>Package software platforms have mixed support.</strong> To be sure, most modern software platforms expose their data via web services. Some will let you query the database directly for information. But, there’s very little consistently. Some platforms expose every tiny function as a service (not very abstract) and some expose giant “DoSomething()” functions that take in a generic “object” (too abstract).</li>
</ul>
<h3>Cloud Considerations</h3>
<p>As far as I can tell, you have three scenarios to support when introducing the cloud to this pattern:</p>
<ul>
<li><strong>Cloud to cloud.</strong> I have one SaaS or custom PaaS application and want to consume data from another SaaS or PaaS application. This should be relatively straightforward, but we’ll talk more in a moment about things to consider.</li>
<li><strong>On-premises to cloud</strong>. There is an on-premises application or messaging engine that wants data from a cloud application. I’d suspect that this is the one that most architects and developers have already played with or built.</li>
<li><strong>Cloud to on-premises</strong>. A cloud application wants to leverage data or processes that sit within an organization’s internal network. For me, this is the killer scenario. The integration strategy for many cloud vendors consists of “give us your data and move/duplicate your processes here.” But until an organization moves entire off-site (if that ever really happens for large enterprises), there is significant investment in the on-premises assets and we want to unlock those and avoid duplication where possible.</li>
</ul>
<p>So what are the  things to think about when doing RPC in a cloud scenario?</p>
<ul>
<li><strong>Security between clouds or to on-premises systems</strong>. If integrating two clouds, you need some sort of identity federation, or, you’ll use per-service credentials. That can get tough to manage over time, so it would be nice to leverage cloud providers that can share identity providers. When consuming on premises services from cloud-based applications, you have two clear choices:
<ul>
<li><strong>Use a VPN</strong>. This works if you are doing integration with an IaaS-based application where you control the cloud environment a bit (e.g. <a href="http://aws.amazon.com/vpc/" target="_blank">Amazon Virtual Private Cloud</a>). You can also pull this off a bit with things like the <a href="http://code.google.com/securedataconnector/" target="_blank">Google Secure Data Connector</a> (for Google Apps for GAE) or <a href="http://www.microsoft.com/windowsazure/features/virtualnetwork/" target="_blank">Windows Azure Connect</a>.</li>
<li><strong>Leverage a reverse proxy and expose data/services to public internet</strong>. We can define a intermediary that sits in an internet-facing zone and forwards traffic behind the firewall to the actual services to invoke. Even if this is secured well, some organizations may be wary to expose key business functions or data to the internet.</li>
</ul>
</li>
<li><strong>There may be additional latency.</strong> For some application, especially based on location, there could be a longer delay when doing these blocking remote procedure calls.  But more likely, you’ll have additional latency due to security.  That is, many providers have a two step process where the first service call against the cloud platform is for getting a security token, and the second call is the actual function call (with the token in the payload).  You may be able to cache the token to avoid the double-hop each time, but this is still something to factor in.</li>
<li><strong>Expect to only use HTTP</strong>. Few (if any) SaaS applications expose their underlying database. You may be used to doing quick calls against another system by querying it’s data store, but that’s likely a non-starter when working with cloud applications.</li>
</ul>
<p>The one option for cloud-to-on-premises that I left out here, <strong>and one that I’m convinced is a differentiating piece of Microsoft software</strong>, is the Azure AppFabric Service Bus.  Using this technology, I can securely expose on-premises services to the public internet WITHOUT the use of a VPN or reverse proxy. And, these services can be consumed by a wide variety of platforms.  In fact, that’s the basis for the upcoming demonstration.</p>
<h3>Solution Demonstration</h3>
<p>So what if I have a cloud-based SaaS/PaaS application, say Salesforce.com, and I want to leverage a business service that sits on site.  Specifically, the fictitious Seroter Corporation, a leader in fictitious manufacturing, has an algorithm that they’ve built to calculate the best discount that they can give a vendor. When they moved their CRM platform to Salesforce.com, their sales team still needed access to this calculation. Instead of duplicating the algorithm in their Force.com application, they wanted to access the existing service. Enter the Azure AppFabric Service Bus.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-10-31int01.png"><img style="display:inline;border-width:0;" title="2011.10.31int01" src="http://seroter.files.wordpress.com/2011/11/2011-10-31int01_thumb.png?w=324&#038;h=360" alt="2011.10.31int01" width="324" height="360" border="0" /></a></p>
<p>Instead of exposing the business service via VPN or reverse proxy, they used the AppFabric Service Bus and the Force.com application simply invokes the service and shows the results.  Note that this pattern (and example) is very similar to the one that I <a href="http://www.amazon.com/gp/product/1849681902/ref=as_li_ss_tl?ie=UTF8&amp;tag=richserosarch-20&amp;linkCode=as2&amp;camp=217153&amp;creative=399701&amp;creativeASIN=1849681902" target="_blank">demonstrated in my new book.</a> The only difference is that I’m going directly at the service here instead of going through a BizTalk Server (as I did in the book).</p>
<h4><strong><span style="color:#000080;">WCF Service Exposed Via Azure AppFabric Service Bus</span></strong></h4>
<p>I built a simple Windows Console application to host my RESTful web service. Note that I did this with the 1.0 version of the AppFabric Service Bus SDK.  The contract for the “Discount Service” looks like this:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:f35e84fe-70cc-4e8e-86d5-e85a1d1d84ca" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; pad-line-numbers: true;">
[ServiceContract]
    public interface IDiscountService
    {
        [WebGet(UriTemplate = &quot;/{accountId}/Discount&quot;)]
        [OperationContract]
        Discount GetDiscountDetails(string accountId);
    }

    [DataContract(Namespace = &quot;http://CloudRealTime&quot;)]
    public class Discount
    {
        [DataMember]
        public string AccountId { get; set; }
        [DataMember]
        public string DateDelivered { get; set; }
        [DataMember]
        public float DiscountPercentage { get; set; }
        [DataMember]
        public bool IsBestRate { get; set; }
    }
</pre></p>
</div>
<p>My implementation of this contract is shockingly robust.  If the customer’s ID is equal to 200, they get 10% off.  Otherwise, 5%.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:36fa7e19-dd3d-4180-8b54-72e3e9715b9b" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
public class DiscountService: IDiscountService
    {
        public Discount GetDiscountDetails(string accountId)
        {
            Discount d = new Discount();
            d.DateDelivered = DateTime.Now.ToShortDateString();
            d.AccountId = accountId;

            if (accountId == &quot;200&quot;)
            {
                d.DiscountPercentage = .10F;
                d.IsBestRate = true;
            }
            else
            {
                d.DiscountPercentage = .05F;
                d.IsBestRate = false;
            }

            return d;

        }
    }
</pre></p>
</div>
<p>The secret sauce to any Azure AppFabric Service Bus connection lies in the configuration.  This is where we can tell the service to bind to the Microsoft cloud and provide the address and credentials to do so. My full configuration file looks like this:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:d8a8a857-4b72-4aba-903c-63a05d0d2b95" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: xml; highlight: [6,9,12,19,25];">
&lt;configuration&gt;
&lt;startup&gt;&lt;supportedRuntime version=&quot;v4.0&quot; sku=&quot;.NETFramework,Version=v4.0&quot;/&gt;&lt;/startup&gt;&lt;system.serviceModel&gt;
        &lt;behaviors&gt;
            &lt;endpointBehaviors&gt;
                &lt;behavior name=&quot;CloudEndpointBehavior&quot;&gt;
                    &lt;webHttp /&gt;
                    &lt;transportClientEndpointBehavior&gt;
                        &lt;clientCredentials&gt;
                          &lt;sharedSecret issuerName=&quot;ISSUER&quot; issuerSecret=&quot;SECRET&quot; /&gt;
                        &lt;/clientCredentials&gt;
                    &lt;/transportClientEndpointBehavior&gt;
                    &lt;serviceRegistrySettings discoveryMode=&quot;Public&quot; /&gt;
                &lt;/behavior&gt;
            &lt;/endpointBehaviors&gt;
        &lt;/behaviors&gt;
        &lt;bindings&gt;
            &lt;webHttpRelayBinding&gt;
              &lt;binding name=&quot;CloudBinding&quot;&gt;
                &lt;security relayClientAuthenticationType=&quot;None&quot; /&gt;
              &lt;/binding&gt;
            &lt;/webHttpRelayBinding&gt;
        &lt;/bindings&gt;
        &lt;services&gt;
            &lt;service name=&quot;QCon.Demos.CloudRealTime.DiscountSvc.DiscountService&quot;&gt;
                &lt;endpoint address=&quot;https://richardseroter.servicebus.windows.net/DiscountService&quot;
                    behaviorConfiguration=&quot;CloudEndpointBehavior&quot; binding=&quot;webHttpRelayBinding&quot;
                    bindingConfiguration=&quot;CloudBinding&quot; name=&quot;WebHttpRelayEndpoint&quot;
                    contract=&quot;IDiscountService&quot; /&gt;
            &lt;/service&gt;
        &lt;/services&gt;
    &lt;/system.serviceModel&gt;
&lt;/configuration&gt;
</pre></p>
</div>
<p>I built this demo both with and without client security turned on.  As you see above, my last version of the demonstration turned off client security.</p>
<p>In the example above, if I send a request from my Force.com application to https://richardseroter.servicebus.windows.net/DiscountService, my request is relayed from the Microsoft cloud to my live on-premises service. When I test this out from the browser (which is why I earlier turned off client security), I can see that passing in a customer ID of 200 in the URL results in a discount of 10%.</p>
<p><a href="http://seroter.files.wordpress.com/2011/11/2011-10-31int02.png"><img style="display:inline;border-width:0;" title="2011.10.31int02" src="http://seroter.files.wordpress.com/2011/11/2011-10-31int02_thumb.png?w=429&#038;h=148" alt="2011.10.31int02" width="429" height="148" border="0" /></a></p>
<h4><strong><span style="color:#000080;">Calling the AppFabric Service Bus from Salesforce.com</span></strong></h4>
<p>With an internet-accessible service ready to go, all that’s left is to invoke it from my custom Force.com page. My page has a button where the user can invoke the service and review the results.  The results may, or may not, get saved to the customer record.  It’s up to the user. The Force.com page uses a custom controller that has the operation which calls the Azure AppFabric endpoint. Note that I’ve had some freakiness lately with this where I get back certificate errors from Azure.  I don’t know what that’s about and am not sure if it’s an Azure problem or Force.com problem.  But, if I call it a few times, it works.  Hence, I had to add exception handling logic to my code!</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:b7497ca4-98d2-4608-a3c1-9bac37238e2d" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
public class accountDiscountExtension{

    //account variable
    private final Account myAcct;

    //constructor which sets the reference to the account being viewed
    public accountDiscountExtension(ApexPages.StandardController controller) {
        this.myAcct = (Account)controller.getRecord();
    }

    public void GetDiscountDetails()
    {
        //define HTTP variables
        Http httpProxy = new Http();
        HttpRequest acReq = new HttpRequest();
        HttpRequest sbReq = new HttpRequest();

        // ** Getting Security Token from STS
       String acUrl = 'https://richardseroter-sb.accesscontrol.windows.net/WRAPV0.9/';
       String encodedPW = EncodingUtil.urlEncode(acsKey, 'UTF-8');

       acReq.setEndpoint(acUrl);
       acReq.setMethod('POST');
       acReq.setBody('wrap_name=ISSUER&amp;wrap_password=' + encodedPW + '&amp;wrap_scope=http://richardseroter.servicebus.windows.net/');
       acReq.setHeader('Content-Type','application/x-www-form-urlencoded');

       //** commented out since we turned off client security
       //HttpResponse acRes = httpProxy.send(acReq);
       //String acResult = acRes.getBody();

       // clean up result
       //String suffixRemoved = acResult.split('&amp;')[0];
       //String prefixRemoved = suffixRemoved.split('=')[1];
       //String decodedToken = EncodingUtil.urlDecode(prefixRemoved, 'UTF-8');
       //String finalToken = 'WRAP access_token=\&quot;' + decodedToken + '\&quot;';

       // setup service bus call
       String sbUrl = 'https://richardseroter.servicebus.windows.net/DiscountService/' + myAcct.AccountNumber + '/Discount';
        sbReq.setEndpoint(sbUrl);
       sbReq.setMethod('GET');
       sbReq.setHeader('Content-Type', 'text/xml');

       //** commented out the piece that adds the security token to the header
       //sbReq.setHeader('Authorization', finalToken);

       try
       {
       // invoke Service Bus URL
       HttpResponse sbRes = httpProxy.send(sbReq);
       Dom.Document responseDoc = sbRes.getBodyDocument();
       Dom.XMLNode root = responseDoc.getRootElement();

       //grab response values
       Dom.XMLNode perNode = root.getChildElement('DiscountPercentage', 'http://CloudRealTime');
       Dom.XMLNode lastUpdatedNode = root.getChildElement('DateDelivered', 'http://CloudRealTime');
       Dom.XMLNode isBestPriceNode = root.getChildElement('IsBestRate', 'http://CloudRealTime');

       Decimal perValue;
       String lastUpdatedValue;
       Boolean isBestPriceValue;

       if(perNode == null)
       {
           perValue = 0;
       }
       else
       {
           perValue = Decimal.valueOf(perNode.getText());
       }

       if(lastUpdatedNode == null)
       {
           lastUpdatedValue = '';
       }
       else
       {
           lastUpdatedValue = lastUpdatedNode.getText();
       }

       if(isBestPriceNode == null)
       {
           isBestPriceValue = false;
       }
       else
       {
           isBestPriceValue = Boolean.valueOf(isBestPriceNode.getText());
       }

       //set account object values to service result values
       myAcct.DiscountPercentage__c = perValue;
       myAcct.DiscountLastUpdated__c = lastUpdatedValue;
       myAcct.DiscountBestPrice__c = isBestPriceValue;

       myAcct.Description = 'Successful query.';
       }
       catch(System.CalloutException e)
       {
          myAcct.Description = 'Oops.  Try again';
       }
    }
</pre></p>
</div>
<p>Got all that? Just a pair of calls.  The first gets the token from the Access Control Service (and this code likely changes when I upgrade this to use ACS v2) and the second invokes the service.  Then there’s just a bit of housekeeping to handle empty values before finally setting the values that will show up on screen.</p>
<p>When I invoke my service (using the “Get Discount” button, the controller is invoked and I make a remote call to my AppFabric Service Bus endpoint. The customer below has an account number equal to 200, and thus the returned discount percentage is 10%.<a href="http://seroter.files.wordpress.com/2011/11/2011-10-31int03.png"><img style="display:inline;border-width:0;" title="2011.10.31int03" src="http://seroter.files.wordpress.com/2011/11/2011-10-31int03_thumb.png?w=450&#038;h=479" alt="2011.10.31int03" width="450" height="479" border="0" /></a></p>
<p>&nbsp;</p>
<h3>Summary</h3>
<p>Using a remote procedure invocation is great when you need to request data or when you send data somewhere and absolutely have to wait for a response. Cloud applications introduce some wrinkles here as you try to architect secure, high performing queries that span clouds or bridge clouds to on-premises applications. In this example, I showed how one can quickly and easily expose internal services to public cloud applications by using the Windows Azure AppFabric Service Bus.  Regardless of the technology or implementation pattern, we all will be spending a lot of time in the foreseeable future building hybrid architectures so the more familiar we get with the options, the better!</p>
<p>In the final post in this series, I’ll take a look at using asynchronous messaging between (cloud) systems.</p>
<br />Filed under: <a href='http://seroter.wordpress.com/category/net/'>.NET</a>, <a href='http://seroter.wordpress.com/category/cloud/'>Cloud</a>, <a href='http://seroter.wordpress.com/category/salesforce-com/'>Salesforce.com</a>, <a href='http://seroter.wordpress.com/category/soa/'>SOA</a>, <a href='http://seroter.wordpress.com/category/wcfwf/'>WCF/WF</a>, <a href='http://seroter.wordpress.com/category/windows-azure-appfabric/'>Windows Azure AppFabric</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/seroter.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/seroter.wordpress.com/1767/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/seroter.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/seroter.wordpress.com/1767/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/seroter.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/seroter.wordpress.com/1767/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/seroter.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/seroter.wordpress.com/1767/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/seroter.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/seroter.wordpress.com/1767/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/seroter.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/seroter.wordpress.com/1767/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/seroter.wordpress.com/1767/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/seroter.wordpress.com/1767/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=seroter.wordpress.com&amp;blog=649486&amp;post=1767&amp;subd=seroter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://seroter.wordpress.com/2011/11/01/integration-in-the-cloud-part-3-remote-procedure-invocation-pattern/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ef5fd2c721814f5491c1f6bfdadf4753?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">rseroter</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-10-31int01_thumb.png" medium="image">
			<media:title type="html">2011.10.31int01</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-10-31int02_thumb.png" medium="image">
			<media:title type="html">2011.10.31int02</media:title>
		</media:content>

		<media:content url="http://seroter.files.wordpress.com/2011/11/2011-10-31int03_thumb.png" medium="image">
			<media:title type="html">2011.10.31int03</media:title>
		</media:content>
	</item>
	</channel>
</rss>
