Click here to Skip to main content
15,880,405 members
Articles / Database Development / SQL Server / SQL Server 2008

Event-Driven Architecture in the Clouds with Windows Azure

,
Rate me:
Please Sign up or sign in to vote.
4.95/5 (23 votes)
5 Feb 2010CPOL14 min read 71K   577   58  
To demonstrate Azure and EDA, this article will show you how to build a flight delay management system for all US airports in clouds with Windows Azure.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using Microsoft.WindowsAzure.ServiceRuntime;
using Microsoft.WindowsAzure.Diagnostics;
using FlightUpdates.Utility.Constants;
namespace FlightUpdates.Utility
{
    /// <summary>
    ///  Manages CloudStorageAccounts used in the flightupdates soultion
    /// </summary>
    public static class CloudStorageUtil
    {
        /// <summary>
        /// Returns CloudStorageAccount for the flight update queue
        /// </summary>
        /// <returns>CloudStorageAccount->FlightUpdatesQueue </returns>
        public static CloudStorageAccount GetFlightUpdatesQueue()
        {
            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
            {
                // Provide the configSetter with the initial value
                configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));

                RoleEnvironment.Changed += (sender, arg) =>
                {
                    if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
                        .Any((change) => (change.ConfigurationSettingName == configName)))
                    {
                        // The corresponding configuration setting has changed, propagate the value
                        if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
                        {
                            // In this case, the change to the storage account credentials in the
                            // service configuration is significant enough that the role needs to be
                            // recycled in order to use the latest settings. (for example, the 
                            // endpoint has changed)
                            RoleEnvironment.RequestRecycle();
                        }
                    }
                };
            });

            return (CloudStorageAccount.FromConfigurationSetting(CloudQueues.FlightDelayMessages));

        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Other
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
Software Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions