The world of .NET and Web Programming

Neuron 2.0 - The WCF and SOA Enabler

I did say we had a bigger announcement and we did. In the last post, I gave the "official" announcement. However, I have a personal and professional relationship with the product and I would like to start a series of posts on it now, as David, the Neuron Architect is doing.

His post gives a detailed paragraph of major features, and indeed, there are a lot! 2.0 has lots of new features over 1.0 and Neuron is a powerful product that enables various scenarios. In designing the product, we didn't want to get religious about what an ESB was. There are plenty of people doing that as well as whether or not an ESB is needed or not. Instead, we wanted to take a practical approach and solve our Microsoft customer problems.

So Neuron came out of real customer scenarios in trying to use the .NET Framework 3.0 (WCF) and other Microsoft technologies. For the purposes One thing we saw was a lack of WCF adoption due to the steep learning curve. People like myself, find it incredibly simpler then the mess of distributed stacks we had to deal with before, but I am in the minority. Moreover, most IT shops don't have developers experienced in this kind of programming. What they have is C# and VB ASP.NET developers, who, as they should be, are focused on delivering business value.

We saw similar pain points in SOA adoption. There are real benefits in SOA but people are either off on vendor exercises or writing a ton of infrastructure code. In either case, the real benefit of Business and IT dynamic alignment and focusing on Business Services has been neglected, leading some people to declare the end of SOA.

We have found, that once you get above a few WCF services, you start to get issues. Services are JBOWS all over the place, instead of being part of an SOA that was developed incrementally with the business drivers and needs. There is no governance. Configs are haphazard. There is no versioning. And so on. So, once you start getting serious about WCF and services, and getting more than five stood up, you start to need infrastructure more and more, putting the "A" in "SOA."

That's a big place I see Neuron fitting in. Let's forget about all the "normal" ESB capabilities for now such as EAI/Integration, Transformation, Mediation, blah, blah. Let's say you are just a WCF or SOA developer. How can I make your life easier? How can I make you 10x or 100x more productive? By taking out the need to write the boilerplate WCF and middleware code, to take out the need for managing config. By taking out all the need to know bindings, transports. What do you really need? You need to get work done! My opinion is that you need Business Events. You need to have infrastructure that says "when this Order comes in, have Microsoft CRM create a customer and have the GP system create a billing record" and have all of that happen without code. In other words, you need to have a Topic Based Publish/Subscribe mechanism with intelligent routing interconnecting endpoints using publish/subscribe messaging and a named topic hierarchy.

You can try to build all this with WCF:

 
    [ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples", SessionMode = SessionMode.Required,         CallbackContract = typeof (ISampleClientContract))]     public interface ISampleContract     {         [OperationContract(IsOneWay = false, IsInitiating = true)]         void Subscribe();          [OperationContract(IsOneWay = false, IsTerminating = true)]         void Unsubscribe();          [OperationContract(IsOneWay = true)]         void PublishPriceChange(string item, double price, double change);     }      public interface ISampleClientContract     {         [OperationContract(IsOneWay = true)]         void PriceChange(string item, double price, double change);     }      public class PriceChangeEventArgs : EventArgs     {         public double Change;         public string Item;         public double Price;     }      // The Service implementation implements your service contract.     [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]     public class SampleService : ISampleContract     {         #region Delegates          public delegate void PriceChangeEventHandler(object sender, PriceChangeEventArgs e);          #endregion          private ISampleClientContract callback;          private PriceChangeEventHandler priceChangeHandler;          //Clients call this service operation to subscribe.         //A price change event handler is registered for this client instance.          #region ISampleContract Members          public void Subscribe()         {             callback = OperationContext.Current.GetCallbackChannel<ISampleClientContract>();             priceChangeHandler = PriceChangeHandler;             PriceChangeEvent += priceChangeHandler;         }          //Clients call this service operation to unsubscribe.         //The previous price change event handler is deregistered.          public void Unsubscribe()         {             PriceChangeEvent -= priceChangeHandler;         }          //Information source clients call this service operation to report a price change.         //A price change event is raised. The price change event handlers for each subscriber will execute.          public void PublishPriceChange(string item, double price, double change)         {             if(item == null) throw new ArgumentNullException("item");             var e = new PriceChangeEventArgs {Item = item, Price = price, Change = change};             PriceChangeEvent(this, e);         }          #endregion          public static event PriceChangeEventHandler PriceChangeEvent;          private void InvokePriceChangeEvent(PriceChangeEventArgs e)         {             PriceChangeEventHandler PriceChangeEventHandler = PriceChangeEvent;             if(PriceChangeEventHandler != null) PriceChangeEventHandler(this, e);         }          //This event handler runs when a PriceChange event is raised.         //The client's PriceChange service operation is invoked to provide notification about the price change.          public void PriceChangeHandler(object sender, PriceChangeEventArgs e)         {             if(callback != null) callback.PriceChange(e.Item, e.Price, e.Change);         }     } }

So, there is 470 lines of that in WCF to build a basic List Based Pub Sub sample which still is pretty yucky. I have to write subscribe/unsubscribe methods, I have to maintain the client list reliably in the face of failures, I can't add or change transports while the system is running and the list goes on and on.

What if I could skip all the code and the three config files, use a GUI tool to identify the Topics and the Publishers and Subscribers and write this instead?

using (Publisher publisher = new Publisher())  {                     publisher.Connect();                                        foreach(var change in changes)                     {                                      publisher.Send("PriceChange", change);                     }
 

Now are down to 3 lines! I would bet that anyone could write that!

So, when you are making an investment in WCF and SOA, think about what you would rather be spending your time on. I know what I would do.

 

» Similar Posts

  1. Enterprise Service Buses (ESB) Drive SOA Adoption - Part 1
  2. Enterprise Service Buses (ESBs) Drive SOA Adoption Part 4
  3. SOA: Making the Paradigm Shift Part 10 of N

Comments are closed