Click here to Skip to main content
15,896,726 members
Articles / Hosted Services / Azure

RoutingService on Azure

Rate me:
Please Sign up or sign in to vote.
4.89/5 (10 votes)
18 Jul 2011CPOL19 min read 60.1K   429   20  
This article describes a design, implementation and usage of the WCF4 Routing Service hosted by Windows Azure.
//*****************************************************************************
//    Description.....ESB Core - Routing
//                                
//    Author..........Roman Kiss, rkiss@pathcom.com
//    Copyright © 2010 ATZ Consulting Inc.     
//                        
//    Date Created:    04/04/10
//
//    Date        Modified By     Description
//-----------------------------------------------------------------------------
//    04/04/10    Roman Kiss     Initial Revision
//
//*****************************************************************************
//  
#region Namespaces
using System;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Xml.Linq;
using System.Xml.XPath;
#endregion

namespace RKiss.RoutingManager
{
    [DataContract(Namespace = "urn:rkiss/2010/09/ms/core/routing")]
    public class RoutingMetadata
    {
        [DataMember]
        public string Config { get; set; }

        [DataMember]
        public bool RouteOnHeadersOnly { get; set; }

        [DataMember]
        public bool SoapProcessingEnabled { get; set; }

        [DataMember]
        public string TableName { get; set; }

        [DataMember]
        public string Version { get; set; }

        public static RoutingMetadata Create(XElement config)
        {
            XElement routing = config.XPathSelectElement("./system.serviceModel/behaviors/serviceBehaviors/behavior/routing");
            var name = routing.Attribute("filterTableName");
            var header = routing.Attribute("routeOnHeadersOnly");
            var soap = routing.Attribute("soapProcessingEnabled");

            return new RoutingMetadata
            {
                Config = config.ToString(),
                TableName = name == null ? string.Empty : name.Value,
                RouteOnHeadersOnly = header == null ? true : System.Convert.ToBoolean(header.Value),
                SoapProcessingEnabled = soap == null ? true : System.Convert.ToBoolean(soap.Value),

            };
        }
    }

    [ServiceContract(Namespace = "urn:rkiss/2010/09/ms/core/routing")]
    public interface IRoutingManager
    {
        [OperationContract(IsOneWay = true)]
        void Refresh(string machineName, string applicationFullName, Guid ticketId);

        [OperationContract(IsOneWay = true)]
        void Set(string machineName, string applicationFullName, Guid ticketId, RoutingMetadata metadata);

        [OperationContract(IsOneWay = true)]
        void Reset(string machineName, string applicationFullName, Guid ticketId);

        [OperationContract(IsOneWay = true)]
        void SendStatus(string machineName, string applicationFullName, Guid ticketId);
    }


}

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
Software Developer (Senior)
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