1 / 34

Building WCF Services with WF in .NET 4.0

Building WCF Services with WF in .NET 4.0.  Ed Pinto PM Microsoft Corporation. Agenda. Motivation WF 4.0 Basics WCF and WF Async I/O Error Handling Correlation Hosting and Monitoring Other WCF 4.0 Improvements. Challenges. Work is increasingly distributed

river
Download Presentation

Building WCF Services with WF in .NET 4.0

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Building WCF Services with WF in .NET 4.0  Ed Pinto PM Microsoft Corporation

  2. Agenda • Motivation • WF 4.0 Basics • WCF and WF • Async I/O • Error Handling • Correlation • Hosting and Monitoring • Other WCF 4.0 Improvements

  3. Challenges • Work is increasingly distributed • Coordination code creates complexity • Coordinating messages with application state • Coordinating calls to a database or another service (Async I/O) • Coordinating rainy day scenarios • Management and tracking of distributed work is difficult

  4. What is WF? Host“Dublin”(IIS/WAS + App Server Extensions)Microsoft ® .NET Workflow Service <your own>.exe Workflow • WF programs coordinate work with minimal ceremony • Activities • Runtime • Tooling Activity Library WF Runtime Tooling VS Designer VS Debugger Rehosted Designer

  5. Activities Activities are the primitive abstraction for behavior Activities are composable with other Activities Activities have user-defined Variables for data storage Activities bind Argumentsto in-scope Variables Activities define Arguments to declare the type of data that can flow into or out of an Activity Flow Chart Variables Sequence OutArgument<Order> Variables Parallel InArgument<TimeSpan> OutArgument<Message> Variables Generate Order Delay Receive Message InArgument<Message> Process Order Send Message Send Report

  6. WCF and WF Workflow Service Host Activity Library Management Endpoint SendMessage Instances Behaviors Persistence ReceiveMessage Tracking Tracking ... … ServiceHostBase

  7. WCF and WF Workflow Service Host Activity Library Management Endpoint SendMessage Instances Behaviors Persistence ReceiveMessage Tracking Tracking ... … ServiceHostBase

  8. Coordinating Asynchronous Concurrency //Simple to author and maintain, performs poorly [OperationContract] public PictureGetPicture(string name) { //blocking I/O byte[] bytes = mediaService.GetMedia(name); return new Picture{ Bytes = bytes, Name = name}; } //Performs well, difficult to author and maintain [OperationContract(AsyncPattern = true)] IAsyncResult public BeginGetPicture(string name, AsyncCallback callback, object state) { return new PictureAsyncResult(name, callback, state); } PictureEndGetPicture(IAsyncResult result) { returnPictureAsyncResult.End(result); }

  9. Coordinating Asynchronous Concurrency //Simple to author and maintain, calls are sequential [OperationContract] public PictureGetPicture(string name) { //blocking I/O byte[] bytes = mediaService.GetMedia(name); //blocking I/O PictureInfoinfo = pictuerInfoService.GetPictureInfo(name); return new Picture{ Bytes = bytes, PictureInfo = info }; } //calls can be made in parallel, difficult to author and maintain [OperationContract(AsyncPattern = true)] IAsyncResult public BeginGetPicture(string name, AsyncCallback callback, object state) { return new BiggerPictureAsyncResult(name, callback, state); } PictureEndGetPicture(IAsyncResult result) { returnBiggerPictureAsyncResult.End(result); }

  10. Coordinating Asynchronous Concurrency Sequence Parallel GetMedia GetMedia GetPictureInfo Other Activities Workflow Runtime Client Operation I/O Scheduler

  11. Coordinating Asynchronous Work PictureService Client GetPicture PictureInfoService GetPictureInfo MediaService GetMedia

  12. demo Coordinating Asynchronous Concurrency

  13. Exceptions Transactions Compensation / Cancellation Coordinating Error Handling Try Catch Finally Sequence Variables Variables Process Message Flow In Transaction Scope Do X CompensableActivity Variables Receive Message Body Exception Handling Logic Compensate X Compensation Logic

  14. Correlation 1. Start Job 123 Application 2. Store Job 123 3. Send Submit TaskJobId = 123 JobId 789 JobId 456 JobId 123 4. Receive 5. Lookup Job 123 Task Complete JobId = 123 6. Job 123 Complete Application State

  15. Correlation SendMessage/ReceiveMessage+ CorrelationHandle Instance Store Channels Correlation Query Context Content (poid=123)

  16. Correlation 1. Start Job 123 Workflow CorrelationHandle 2. Send 3. Store workflow with query results SendMessage Submit Task JobId 789 JobId 456 JobId 123 4. Receive 5. Lookup workflow using query results ReceiveMessage Task Complete Application State JobId = 123 JobId = 123 Correlation Query Correlation Query JobId=123 JobId=123 Query Results Query Results 6. Job 123 Complete

  17. Correlation PictureService Client GetPicture PictureInfoService GetPictureInfo Picture PictureInfo Context Based Correlation Context Based Correlation Content Based Correlation GetMedia MediaService Media

  18. demo Message Correlation

  19. Hosting and Monitoring WCF + WF + "Dublin" • IIS Manager • Management • Control • Enumeration • Tracking Workflow Service Host Management Endpoint PowerShellManagement APIs Instances [OperationContract] public void SubmitOrder(Order order){ // your code here } Persistence Tracking Tracking Tracking Site/Service Configuration IIS/WAS

  20. demo Hosting and Monitoring

  21. When Should I Write WCF Services using Workflow? • Consider Workflow Services if your service: • Calls a database, calls another service, or uses the file system • Coordinates parallel work • Enforces ordering between messages • Coordinates messages with application state • Is long running • Requires rich tracking information

  22. Other WCF 4.0 Improvements • REST toolkit • Discovery • Local Services • New Channels: UDP, Http Polling Duplex • Standards: SOAP over UDP, BP 1.2 • Standard Endpoints • Durable Duplex • Simplified Config And much much more….

  23. Conclusion • WF and WCF push complex coordination to the framework • Async I/O • Error Handling • Correlation • WF and WCF make service state queryable • “Dublin” provides enterprise • Persistence • Tracking • Management • More …

  24. Resources • Breakout Sessions • BB18 - "Dublin": Hosting and Managing Workflows and Services • TL38 - WCF: Zen of Performance and Scale • TL35 - WCF: Developing RESTful Services • TL17 - WF 4.0: A First Look • TL21 - WF 4.0: Extending with Custom Activities • TL36 - Microsoft .NET Framework: Declarative Programming Using XAML • BB27 - .NET Services: Orchestrating Services and Business Processes Using Cloud-Based Workflow • http://msdn.microsoft.com/wcf/future/ • http://msdn.microsoft.com/wf/future/ • Questions to wfpdc@microsoft.com

  25. Evals & Recordings Please fill out your evaluation for this session at: This session will be available as a recording at: www.microsoftpdc.com

  26. Q&A Please use the microphones provided

  27. © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

  28. Correlation SendMessage/ReceiveMessage+ CorrelationHandle Instance Store Channels Correlation Query Cookies Context Body Content (poid=123)

  29. WCF + WF WCF WCF + WF + "Dublin" Tools Trace Viewer Test Client Config Editor Designer Debugger Workflow Service Host • IIS Manager • Management • Control • Enumeration • Tracking Activity Library Management Endpoint Management Endpoint SendMessage ReceiveMessage … PowerShellManagement APIs Behaviors Service Host Metadata Instances Instances [OperationContract] public void SubmitOrder(Order order) { // your code here } Persistence … Tracking Tracking Tracking … Channels (HTTP, TCP, NamedPipes, …) Site/Service Configuration IIS/WAS

  30. WCF 4.0 Improvements • Rest toolkit • Standards: • SOAP over UDP, WS-Discovery, WS-BA, WS-RSP, BP 1.2 • Local Services • New Channels • UDP, Polling Http Duplex • Discoverable services • Programming model simplifications • Standard Endpoints • Config • …

  31. What is WF? Host • WF programs coordinate work with minimal ceremony • Activities • Runtime • Tooling Workflow Activity Library WF Runtime Tooling VS Designer VS Debugger Rehosted Designer

  32. Correlation 1. Receive Application 2. Store PO 123 Submit OrderPOId = 123 POId 789 POId 456 3. Receive POId 123 4. Lookup PO 123 Update OrderPOId = 123 5. Store PO 123 Application State

  33. Coordinating Asynchronous Work PictureService Client Picture GetPicture(Name) MediaService XamlGetMedia(Name) PictureInfoService PictureInfoGetPictureInfo(Name)

More Related