Archive for the ‘WCF’ Category

Connected Systems and BizTalk

Wednesday, November 14th, 2007

Last night I went to the launch of the San Diego Connected Systems SIG (and here). Brian (along with Chris Romp) gave a great overview of BizTalk Server 2006 R2.

I have never used BizTalk and had little knowledge of its capabilities going in. BizTalk reference material and articles can be found in numerous places on the web -- a good summary is Introducing BizTalk Server 2006 R2 (pdf).

My major take-aways from the presentation were:

  • BizTalk is an enterprise class product -- i.e. a heavy weight solution designed to scale for very large business needs (global reach, high throughput, tight control and policies, highly reliable).
  • As such, the learning curve is steep.
  • BizTalk uses a message oriented architecture designed to connect disparate systems of all types.
  • Some of the key BizTalk tools include:
    • Sending and receiving messages with Adapters
    • Orchestrations
    • Business Rule Engine
    • Message processing with Pipelines
    • Message translation with Data Mapping
    • Business Activity Monitoring (BAM)
  • BizTalk uses a publish/subscribe model that allows for asynchronous message handling.
  • Most development tools are integrated into Visual Studio. Some of the visual message mapping needs present real GUI challenges.
  • BizTalk Server 2006 R2 will include Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) integration. WF will not replace Orchestrations.
  • Microsoft SQL Server is used as the back-end database and is very tightly bound to BizTalk functionality and performance. The message persistence capability of the Message Box is a powerful built-in tool.
  • The Microsoft Enterprise Service Bus (ESB) Guidance further uses BizTalk to support a loosely coupled messaging architecture.
  • BizTalk will also be a key component of Microsoft's new service-oriented architecture (SOA) framework called Oslo.

Because of its message handling architecture it's easy to see how HL7 translation and routing could be accomplished. Microsoft provides accelerators (pre-defined schema, orchestration samples, etc.) for HL7 and HIPAA for this purpose.

It's not hard to understand the importance of BizTalk in the larger Enterprise space. It appears to be benefiting from its years of prior experience and continued integration with other evolving Microsoft technologies. Overall, I was very impressed with BizTalk.

A Note on Special Interest Groups

I'm not only lucky to have a SIG like this in the area, but it's also great to have people as knowledgeable (and friendly) as Brian and Chris running it. Great job guys!

I would encourage everyone to seek out and attend their local user/developer group meetings. Don't just go for the free pizza (which usually isn't that good anyway) -- it's a great way to improve yourself both technically and professionally. You'll also get to meet new people that have the same interests as you.

I think that getting exposure to technologies that you don't use in your day-to-day work can be just as rewarding as becoming an expert in your own domain. Learning about cutting-edge software (or hardware) is exciting no matter what it is. That new knowledge and perspective also has the potential to lead you down roads that you might not have considered otherwise.

A .NET code sample: Real-time data streaming and control.

Monday, September 24th, 2007

This is a follow-up to the Developing a real-time data flow and control model with WCF post. My original plan was to write a full-fledged article on this. I've gotten some requests for the code, but it does not appear that I'm going to have time to complete the article in the near future. So I thought I'd just give a brief description here of what I've done so far and provide the code as is.

Please Note: The description provided is very brief and only meant as an overview. None of the implementation details are included here. It's not a very complicated project. If you have some VS2005 development experience and are willing to dig into the code, you shouldn't have a problem figuring it all out. Working through this code would provide a good first tutorial on developing with WCF. Some set-up is required (service installation) and is described below.

Motivation:

I originally conceived of this project because of some questions I'd heard from real-time C/C++ developers. They wanted to know about migrating from MFC/VC++ to .NET managed code. The primary concern was about the use of legacy device level code and how to manage future mixed development projects.

So my first thought was to demonstrate how easy straight forward it is to incorporate COM components into managed code with .NET wrappers. There are already many good articles on integrating old Win32 projects into .NET. e.g. Do you COM? Dealing with Legacy Projects. This project is a concrete example of how that can be done.

It also illustrates a model of the type of real-time data streaming and control typically required by a physiological monitor.

To extend that model, I wanted to show how WCF could be used as a network transport for that same data stream. Hence the previous post. The addition of a WCF client application that provided a real-time display of the data stream was only logical.

There are a number of directions that I had planned on taking this project, but that will have to wait for another day. I'm sure that you'll come up with your own ideas along with numerous improvements.

The Code:

The download (below) is a Visual Studio 2005 solution, called RealTimeTemplate, with 6 projects (one is C++, all the rest are C#). Here is a diagram of the projects and their relationship. The horizontal arrows show the data flow as described above.

Real-time Template Components

The projects are:

  • SineWaveGenerator: This is a C++ COM component that generates buffers of multi-channel sine waves.
  • SineWaveGenerator.Test: The NUnit test functions for SineWaveGenerator
  • SineWaveWCFLib: This is the WCF server component.
  • SineWaveWCFServer: This the Windows service that hosts the WCF service (SineWaveWCFLib).
  • SineWaveWCFService.Test: The NUnit tests functions for SineWaveWCFService.
  • RealTimeDisplayWinForm: This is the Windows Form class, and WCF client, that controls and displays the sine wave data provided by the service. The graphical display is done using the ZedGraph library.

Here is what the Windows Form looks like when the application is running.

Real-time Template WinForm

Service Installation:

In order to run the sine wave display application, you'll first have to install and start the SineWaveWCFService.

  1. Build the solution in Debug configuration.
  2. Execute the InstallSineWaveWCFService.bat in SineWaveWCFService\bin\Debug. The service can be un-installed with the UninstallSineWaveWCFService.bat script.
  3. Run the Windows Services Manager (services.msc) and Start SineWaveWCFService.
  4. Run the RealTimeDisplayWinForm project. Use the Add button to add sine wave displays.

The source code can be downloaded here:

RealTimeTemplate_20070923.zip (210K)

Enjoy!

Developing a real-time data flow and control model with WCF

Saturday, August 11th, 2007

A Windows Communication Foundation (WCF) service is defined through its operations and data contracts. One of the major benefits of WCF is the ease with which a client can create and use these services through the automatically generated proxy classes. The service side is only half of the communications link though. Discovering the correct WCF configuration options that allow a solution to operate properly was not as easy as I thought it would be.

This post describes a specific WCF-based data control and streaming architecture. The primary goal of this service is to provide a continuous data stream (as buffers of short values) from a real-time data acquisition source. The client would then be able to display the data as it became available or store the data when directed by the user. In addition, the service allows the client to both get status information (Getters) and control certain attributes (Setters) of the underlying data source. This is illustrated here:

Real-time architecture

The DataBufferEvent is defined as a one-way callback and continuously delivers data to the client. The IsOneWay property is valid for any operation that does not have a return value and improves network performance by not requiring a return message. The Getters and Setters [for you Java folks, this has nothing to do with JavaBeans] can be called at any time. Changing a data source attribute with a Setter will probably affect the data stream, but it is the responsibility of the data source to ensure data integrity. The underlying transport binding must support duplex operation (e.g. wsDualHttpBinding or netTcpBinding) in order for this scenario to work.

Here is what an example (a sine wave generator) service interface looks like:

The service class is implemented as follows:

The InstanceContextMode.PerSession mode is appropriate for this type of interface. Even though there is probably only a single data source, you still want to allow multiple service session instances to provide data simultaneously to different clients. The data source would be responsible for managing the multiple data requesters.

With the service side complete, all the client needs is to do is create the proxy classes (with either Visual Studio or Svcutil), setup the DataBufferEvent callback and call the appropriate control functions. My first client was a Winform application to display the data stream. The problem I ran into is that even though the data callbacks worked properly, I would often see the control functions hang the application when they were invoked.

It took quite a bit of searching around before I found the solution, which is here. You can read the details about the SynchronizationContext issues, but this caused me to spin my wheels for several days. The upside is that in trying to diagnose the problem I learned how to use the Service Trace Viewer Tool (SvcTraceViewer.exe) and the Configuration Editor Tool (SvcConfigEditor.exe, which is in the VS2005 Tools menu).

So after adding the appropriate CallbackBehavior attributes, here are the important parts of the client that allow this WCF model to operate reliably:

The first take-away here is that WCF is a complex beast. The second is that even though it's easy to create proxy classes from a WCF service, you have to understand and take into account both sides of the communications link. It seems so obvious now!

That's it. This WCF component is just part of a larger project that I'm planning on submitting as an article (with source code) on CodeProject, someday. If you'd like the get a copy of the source before that, just let me know and I'll send you what I currently have.

Update: Proof of my first take-away: Callbacks, ConcurrencyMode and Windows Clients. Thanks Michele! 🙂