Vous êtes sur la page 1sur 82

Windows Communication

Framework
Technical Drilldown
Jeff Brand
.NET Architect
Microsoft – Minneapolis
jbrand@microsoft.com
http://www.slickthought.net
Agenda

Intro
The Basics
Understanding Bindings
Reliable Messaging
Security
What is .NET 3.0?
Formerly WinFX
New managed code programming model for
Windows
Combines the power of the .NET Framework 2.0
with new technologies for building applications
Visually compelling user experiences
Seamless communication across technology boundaries
Ability to support a wide range of business processes
Runs on Windows XP SP2, Windows Server 2003
SP1 and Windows Vista

Downloads, demos, presentations and more at


http://www.netfx3.com
What is .NET 3.0?

Comprised of four main technologies


Windows Communication Foundation (“Indigo”)
Windows Workflow (“WinOE”)
Windows Presentation Foundation (“Avalon”)
Windows CardSpace (“InfoSpace”)
Includes extensions to Visual Studio 2005
to aid in application creation
Looking at WCF
Why?
What is the purpose of the Windows Communication
Foundation?

What?
What is the Windows Communication Foundation?

How?
How to use the Windows Communication Foundation?
Distributed Stacks Today

Services Queuing Components Objects


Interoperable Reliable Msg Transactions Extensible
ASP.NET Infrastructure CLR Infrastructure
COM+ Infrastructure
MSMQ Infrastructure

Each stack has different strengths, target scenarios


Customers want to mix and match, compose
Reliable services
Interoperable transactions
The Union of Today’s Stacks

WCF

Message- Attribute-
WS-* Composability SOA
Oriented Based
Protocols Extensibility Interop
Programming Programming
The ABCs of Windows Communication
Foundation
A set of .NET 2.0 classes for building software services

Deploy at some Address


Within any .NET assembly—console, windows, service
Within IIS 5.1 or 6 or IIS 7 Windows Activation Service
Enjoy rich management interfaces out of the box:
perf counters, WMI, tracing and more
Connect to any topology by selecting & switching Bindings
Standard bindings—eg. for max interop, or max perf.
Custom bindings—for any transport, encoding and protocols
Define explicit interfaces as Contracts
Behavioral contracts—define what your software will do
Structural contracts—define the formats of inputs and outputs
How to use the Windows Communication
Foundation?
Client:
Service:
• Download
• Define Contracts
Metadata
• Implement
• Generate Proxy
Contracts
Program • Invoke Proxy
• Provide host
Methods

• Configure • Generate Binding


Binding
• Generate Address
• Configure
Administ Address • Monitor
er
• Monitor
Using Windows Communication Foundation
(Service Programmer) Define Contracts
[DataContract(Name=“ProspectiveDeal”,Namespace=“WoodgroveBank”)]
public class Deal
{
[DataMember(Name=“StockSymbols”)]
public string[] Symbols;

[DataMember(Name=“TimeStamp”)]
private DateTime when

[DataMember(Name=“Date”)]
public DateTime When{ get{return this.when;}}
}
[DataContract(Name=“DealAnalysis”,Namespace=“WoodgroveBank”)]
public class Analysis
{
[DataMember]
public decimal Value;
[DataMember]
public decimal RiskFactor;
}

[ServiceContract(Name=“DealService”,Namespace=“WoodgroveBank”)]
public interface IDeal
{
[OperationContract(Name=“Analyze”)]
Analysis AnalyzeDeal(Deal dealToAnalyze);

[OperationContract(Name=“Execute”,IsOneWay=true)]
void ExecuteDeal(Deal dealToExecute)
}
Using the Windows
Communication
Foundation
Contracts

Structural c E

DataContract n
d
MessageContract
Program p
Behavioral o
ServiceContract i
OperationContract n
FaultContract t
Structural Contracts: Data
Contracts
Uncertainty/Polymorphism: c E
The other use for the KnownType attribute n
d
Program p
[DataContract] o
public class book{…}
i
[DataContract]
public class magazine{…} n
t
[DataContract]
[KnownType(typeof(Book))]
[KnownType(typeof(Magazine))]
public class PublishedItem
{
[DataMember]
object catalog;
[DataMember]
DateTime publicationDate;
}
Structural Contracts: Data
Contracts
Dealing with collections: c E

Use the KnownType attribute n


d
Program p
[DataContract] o
public class book{…}
i
[DataContract]
public class magazine{…}
n
t
[DataContract]
[KnownType(typeof(Book))]
[KnownType(typeof(Magazine))]
public class LibraryCatalog
{
[DataMember]
System.Collections.Hashtable catalog;
}
Structural Contracts: Message
Contracts
Defines the message structure on the
wire E
c
The MessageBody is typically a n
DataContract d
Program
For custom SOAP headers p
[DataContract]
public class PurchaseOrder
o
{ i
[DataMember]
public Customer customer; n
[DataMember]
public Item[] items; t
}

[MessageContract]
public class PurchaseOrderMessage
{
[MessageHeader]
public int Number;
[MessageBody(Order=1)]
public PurchaseOrder Order;
}
Using Windows Communication Foundation
(Service Programmer) Implement Contracts

[ServiceContract(Name=“DealService”,Namespace=“WoodgroveBank”)]
public interface IDeal
{ … }

public class DealAnalyzer: IDeal


{
Analysis IDeal.AnalyzeDeal(Deal dealToAnalyze)
{

return Analysis;
}

void IDeal.ExecuteDeal(Deal dealToExecute)


{

return;
}
}
Behavioral Contracts: Service
Contracts
Inheritance c E
for versioning n

for multiple contracts at one endpoint d


Program p
o

[ServiceContract] i
public interface IOrderEntry
n
{
[OperationContract(IsOneWay=true)] t
void PlaceOrder(PurchaseOrder order);
}

[ServiceContract]
public interface IExtendedOrderEntry: IOrderEntry
{
[OperationContract]
PurchaseOrder GetOrder(String orderIdentifier);
}
Behavioral Contracts: Service
Contracts
Controlling how structural c E

contracts serialize n
d
Program p
[ServiceContract] o
[DataContractFormat(Style=OperationFormatStyle.Document)] //Or Rpc
public interface IOrderEntry i
{
n

} t
[ServiceContract]
[XmlSerializerFormat(Style=OperationFormatStyle.Document,
Use=OperationFormatUse.Literal)] //Or Encoded
public interface IOrderEntry
{

}
Behavioral Contracts: Service
Contracts
Duplex type c E
n
d
Program p
o

[ServiceContract(Session=true,CallbackContract=typeof(IOrderEntryCallback))]i
public interface IOrderEntry
n
{
[OperationContract(IsOneWay = true)] t
void PlaceOrder(PurchaseOrder order);
}

[ServiceContract]
public interface IOrderEntryCallback
{
[OperationContract(IsOneWay = true)]
void PlaceOrderCompleted(PurchaseOrderStatus orderStatus);
}
Behavioral Contracts: Operation
Contracts Use the OperationContractAttribute properties to
control the translation of the method signature into
WSDL:
E
The AsyncPattern property indicates that the c
operation is implemented asynchronously using a n
Begin/End method pair.
The IsOneWay property indicates that the operation d
only consists of a single input message. The
Program operation has no associated output message. p
The IsInitiating property specifies whether this
operation can be the initial operation in a session. o
The IsTerminating property specifies whether WCF
attempts to terminate the current session after the i
operation completes.
The Action property specifies the action that n
uniquely identifies this operation. WCF dispatches
request messages to methods based on their action. t
The ReplyAction property specifies the action of the
reply message for the operation.

[ServiceContract]
public interface IOrderEntry
{
[OperationContract(IsOneWay=true)]
void PlaceOrder(PurchaseOrder order);
}
Behavioral Contracts: Operation
Contracts
Action Property c E
use a wildcard action to provide a n
default message handler d
Program p
[ServiceContract]
o
public interface MyContract
{ i
[OperationContract(IsOneWay = true,
Action="urn:crud:insert")] n
void ProcessInsertMessage(Message message);
t
[OperationContract(IsOneWay = true,
Action="urn:crud:update")]
void ProcessUpdateMessage(Message message);

[OperationContract(IsOneWay = true,
Action="urn:crud:delete")]
void ProcessDeleteMessage(Message message);

[OperationContract(IsOneWay = true, Action="*")]


void ProcessUnrecognizedMessage(Message message);
}
Behavioral Contracts: Fault Contracts
[DataContract]
public class MyFault
{
[DataMember]
string Reason = null; E
} c
n
[ServiceContract]
public interface IOrderEntry d
{
p
[OperationContract]
[FaultContract(typeof(MyFault))] o
PurchaseOrder GetOrder(String orderIdentifier);
} i

public class OrderEntry: IOrderEntry n


{ t
public PurchaseOrder GetOrder(string orderIdentifier)
{
try{…}
catch(Exception exception)
{
MyFault theFault = new MyFault();
theFault.Reason = “Some Reason”;
throw new FaultException<MyFault>(theFault);
}
}
}
Behavioral Contracts: Fault Contracts

Client view: c E
n
d
Program p
[DataContract(Name=”MyFault”)] o
public class ClientFault
{ i
[DataMember]
n
string Reason = null;
} t

try
{
PurchaseOrder order = Service.GetOrder(orderIdentifier);
}
catch (FaultException<ClientFault> clientFault)
{
Console.WriteLine(clientFault.Reason);
}
Using Windows Communication Foundation
(Service Programmer) Provide Host

[ServiceContract(Name=“DealService”,Namespace=“WoodgroveBank”)]
public interface IDeal
{ … }

public class DealAnalyzer: Ideal


{ … }

public class Program


{
static void Main(string[] args)
{
using (ServiceHost host = ServiceHost(typeof(DealAnalyzer)))
{
host.Open();

Console.WriteLine(“The service is running.");


Console.ReadLine();
}
finally
{
host.Close();
}
}
}
Using Windows Communication Foundation
(Client Programmer) Download Metadata
(Client Programmer) Generate Typed Proxy
(Client Administrator) Generate Address
(Client Administrator) Generate Binding
SvcUtil.exe “http://localhost:8080/Deals/AnalysisService”
/out:DealAnalysisProxy.cs /config: app.config

(Client Programmer) Invoke Typed Proxy


Deal deal = new Deal();
… Methods

using(DealAnalysisProxy analysisProxy = new DealAnalysisProxy(“DealAnalyzer”)


{
analysis = analysisProxy.AnalyzeDeal(deal);
}
finally
{
analysisProxy.Close();
}
Service Implementation: Hosting

WCF services can be c E

hosted in any .Net n


d
Program
Application Domain
p
This provides many o
options out of the box for i

rich client applications n

(WPF or WinForms), t

Windows Services, IIS Service

(WAS)
Choosing the hosting
model depends on the
requirements of your
Service Implementation: Hosting
In standalone executables
E
c
n
Program
d
[ServiceContract]
public interface ILenderService {…} p

internal class LenderService: ILenderService {…} o


i
public class Program
{ n
static void Main(string[] args)
{ t
using (ServiceHost host = ServiceHost(typeof(LenderService)))
{ Service
host.Open();
Console.WriteLine(“The service is running.");
Console.ReadLine();

}
}
}
Service Implementation: Hosting
In an Managed Windows Service
Benefits:
Process lifetime controlled by O/S E
c
Built-in Service Control Manager n
Program d
[ServiceContract] p
public interface ILenderService {…}
o
internal class LenderService: ILenderService {…}
i
public partial class MyManagedService : ServiceBase
{ n
private ServiceHost host = null;
t
public MyNTService(){ InitializeComponent(); }
Service
protected override void OnStart(string[] args)
{
this.host = new ServiceHost(typeof(LenderService ));
service.Open();
}

protected override void OnStop()


{
host.Close();
}
}
Service Implementation: Hosting
IIS 5.1 & 6 support HTTP only
Windows Activation Services E
supports HTTP, TCP, Named c
n
Pipes
d
Program WAS also provides activation of p
service classes on the arrival of o
//LenderService.cs a request i
using System.ServiceModel;
n
namespace MyNamespace
t
{
[ServiceContract]
public interface ILender {…} Service

internal class LenderService: ILender {…}


}

//LenderService.svc
<%@Service Class="MyNamespace.LenderService" %>
<%@Assembly Name=“LenderServiceAssembly" %>
Bindings

Bindings = c E
Transports + n

Encoders + d
Deploy p
Protocols
o
i
b n
t

Service
Windows Communication Foundation
Architecture

User Code User Code

Typed Proxy Dispatcher

Protocol B B Protocol
i i
n n
Encoding d d Encoding
i i
n n
Transport g g Transport

Message
Bindings: Transports

HTTP c E

TCP n
d
Deploy Named Pipes p

MSMQ o
i
b n
t

Service
Binding Options: The Standard Bindings

Interop.

Security

Session
s
Transaction
Duplex
BasicHttpBinding BP 1.1 T
WsHttpBinding WS T|S X X
WsDualHttpBinding WS T|S X X X
NetTcpBinding .NET T|S X X X
NetNamedPipesBinding .NET T|S X X X
NetMsmqBinding .NET T|S X X
MsmqIntegrationBinding .NET T
NetPeerTcpBinding .NET T|S X
T = Transport Security | S = WS-Security Message Security
Bindings: Encoding

Text c E
for interoperability n
d
Deploy Binary
p
for hi-speed WCF-to-WCF
o
MTOM i
Message Transmission b n
Optimization Protocol t

for incorporating binary attachments


Service
Bindings: MTOM Encoding
Problem: How to send binary data to a service in
SOAP?
Solution One:
c E
2. SOAP is XML n
d
3. XML provides Base64 Encoding
Deploy p
⇒ Express binary data in Base64 o

⇒ Embed in SOAP XML document i


b n
Snag:
t
Base64 encoding increases size by 1.33 Service
Bindings: MTOM Encoding
Problem: How to send binary data to a service in
SOAP?
Solution Two:
c E
2. Put the XML of the SOAP message n
d
3. … and the binary data into a MIME doc
Deploy p
4. Put a link in the SOAP to the binary data o
i
b n
Snag:
t
Encrypting the SOAP misses the binary data
Service
Bindings: MTOM Encoding
Problem: How to send binary data to a service in
SOAP?
MTOM Solution:
c E
2. Express the binary data in Base64 n
d
3. Incorporate into SOAP XML
Deploy p
4. Encrypt SOAP document o

5. Take the binary data out of the document i


b n
6. Convert it back out of Base64
t
7. Put SOAP & binary data into a MIME docService
8. Put a link in the SOAP to the binary data
Bindings: MTOM Encoding
WCF Implementation
Simply select MTOM as the encoding
E
All byte[] and Stream data gets “MTOM’d” c
n
MTOM transmits an XML message as a MIME d
message p
One MIME part that contains the XML in textual o
form
i
The other MIME parts that contain the binary data b n
that has been optimized
t
The other MIME parts of the message are not encoded
as text but transmitted separately as binary data. Service
The textual XML MIME part refers to the other,
binary MIME parts in various places
This is equivalent to this binary data being included
in the textual XML
The entire MIME message forms one XML infoset.
Bindings: Protocols
Might include,
E
c
WS-Security n
d
WS-Reliable Messaging
Deploy p
WS-Coordination and Transaction
o
i
b n
t

Service
Bindings

Binding options: c E
Select a standard binding n

Customize a standard binding d


Deploy p
Define a custom binding
o
Configuring bindings i
Configure in a configuration file b n
Create and configure in code t

Service
Using Windows Communication Foundation
(Service Administrator) Configure Binding
(Service Administrator) Configure Address

<!--App.Config (hosted in .NET Assembly) or Web.Config (hosted in IIS)-->


<configuration>
<system.serviceModel>
<services>
<service serviceType=“DealAnalyzer”>
<endpoint
address=“http://localhost:8080/Deals/AnalysisService”
binding=“wsHttpBinding”
contract=“IDeal”/>
</service>
</services>
</system.serviceModel>
</configuration>
Binding Options: The Standard Bindings
Selecting a standard binding

<configuration>
<system.serviceModel>
<services>
<service serviceType=“DealAnalyzer”>
<endpoint
address=“http://localhost:8080/Deals/AnalysisService”
binding=“wsHttpBinding”
contract=“IDeal”/>
</service>
</services>
</system.serviceModel>
</configuration>
Gotcha:
Initial characters of
binding names in
lowercase in config.
Binding Options: Modified Standard Bindings

<configuration>
<system.serviceModel>
<services>
<service serviceType=“DealAnalyzer”>
<endpoint
address=“http://localhost:8080/Deals/AnalysisService”
binding=“wsHttpBinding”
bindingConfiguration=“ReliableHttp”
contract=“IDeal”/>
</service>
</services>
<bindings>
<wsProfileBinding>
<binding configurationName=“ReliableHttp“>
<reliableSession Enabled=“true”/>
</binding>
</wsProfileBinding>
</bindings>
</system.serviceModel>
</configuration>
Binding Options: Custom Bindings
In code:
public static void Main(string[] args)
{
ServiceHost host = new ServiceHost(typeof(MathService),
“net.tcp://localhost/8080/MathService/”);

ReliableSessionBindingElement r = new ReliableSessionBindingElement();


r.AdvancedFlowControl = true;

SecurityBindingElement s =
AsymmetricSecurityBindingElement.CreateKerberosBinding();

HttpTransportBindingElement t = new HttpTransportBindingElement();


t.MaxMessageSize = long.MaxValue;

TextMessageEncodingBindingElement e =
new TextMessageEncodingBindingElement();

CustomBinding binding = new CustomBinding(new


BindingElement[]{r,s,t,e});

EndpointAddress address = “net.tcp://localhost/8080/Math/”;


host.AddEndpoint(typeof(IMath), binding, address);

host.Open();
}
Binding Options: Custom Bindings
In configuration:
<?xml version=“1.0” encoding=“UTF-8” ?>
<configuration>
<system.serviceModel>
<services>
<service serviceType=“DealAnalyzer”>
<endpoint address=“http://localhost:8080/Deals/AnalysisService”
binding=“customBinding”
bindingConfiguration=“ReliableHttp”
contract=“IDeal”/>
</service>
</services>
<bindings>
<customBinding>
<binding configurationName=“ReliableHttp">
<reliableSession ordered="true” />
<security authenticationMode=“Kerberos” />
<textMessageEncoding />
<httpTransport maxMessageSize=“9223372036854775807" />
</binding>
</customBinding>
</bindings>
</system.serviceModel>
</configuration>
Security
WCF Security in a Nutshell

WCF security does two things


Secures message exchange between entities
Secures access to resources by entities

Entity == person, company, software, …


Resource == file, service, operation, …
Messaging Security Requirements

Confidentiality
Integrity
Authentication
Authorization
Auditing
Credential

Claims
Information about an entity
Used to control access to resources
Issuer
Certifies claims in the credential
Proof of possession
How an entity proves it provided the claims
Credential Examples

Alice

Username

MyDomain\Alice

Kerberos
Subject: CN=Alice
Issuer: SomeCA
ValidFrom: 2005-09-13
ValidUntil: 2005-09-16
Certificate
WCF Security Model

Based on credentials and claims


Can satisfy security requirements
Secure by default
Consistent across bindings
Consistent across credentials
Transport Security

Security requirements satisfied at


transport layer
Advantages
Performance benefits
Common implementation
Disadvantages
Restricted claim types
No security off the wire
Transport Security
<endpoint address=“https://localhost/calculator"
binding=“basicHttpBinding“
bindingConfiguration=“Binding1”
contractType="ICalculator" />

<basicHttpBinding>
<binding configurationName="Binding1">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicProfileBinding>
Message Security

Security requirements satisfied at


message layer
Advantages
More credential types
Extensible
Securing selected parts of messages
End-to-end security
Disadvantages
Standards and usage still solidifying
Performance impact
Message Security
<endpoint address=“http://localhost/calculator"
binding=“wsHttpBinding“
bindingConfiguration=“Binding1”
contractType="ICalculator" />

<wsHttpBinding>
<binding configurationName="Binding1">
<security mode="Message">
<message clientCredentialType=“Windows"/>
</security>
</binding>
</wsHttpBinding>
Mixed Mode

Compromise between Transport and


Message Security
Transport layer satisfies integrity and
confidentiality requirements
Performance benefits
Message layer carries claims
Rich credentials, extensibility
Mixed Mode Security
<endpoint address=“https://localhost/calculator"
binding=“wsHttpBinding“
bindingConfiguration=“Binding1”
contractType="ICalculator" />

<wsHttpBinding>
<binding configurationName="Binding1">
<security mode="TransportWithMessageCredential">
<message clientCredentialType=“Windows"/>
</security>
</binding>
</wsHttpBinding>
Username/Password

Console.WriteLine(" Enter username[domain\\user]:");


string username = Console.ReadLine();
Console.WriteLine(" Enter password:");
string password = Console.ReadLine();

CalculatorProxy proxy = new CalculatorProxy();


proxy.ChannelFactory.Credentials.
UserNamePassword.UserName = username;
proxy.ChannelFactory.Credentials.
UserNamePassword.Password = password;
Impersonation
[OperationBehavior(Impersonation=
ImpersonationOption.Required)]
public double Add(double n1, double n2)
{
return n1 + n2;
}

public double Add(double n1, double n2)


{
using (ServiceSecurityContext.Current.
WindowsIdentity.Impersonate())
{
return n1+n2;
}
}
PrincipalPermission
[PrincipalPermission(SecurityAction.Demand,
Role = "Builtin\\Administrators")]
public double Add(double n1, double n2)
{
double result = n1 + n2;
return result;
}

<behaviors>
<behavior configurationName="CalculatorServiceBehavior">
<serviceAuthorization
principalPermissionMode="UseWindowsGroups" />
</behavior>
</behaviors>
Federated Credentials
I’m Alice
Client Service
(SAML)

I’m Alice Here’s a


(X.509) Credential
(SAML)

Trust Relationship
Credential Issuer
Federated Credentials

Issued by third party


Based on provided credentials
Supports arbitrary credentials
Benefits:
Facilitates trust relationships across organizations
Delegation of claim checks to dedicated sources
Rich credential support
Reliability
Challenges Of Reliable Distributed
Systems

Communication Processing Issues


Messages lost when
Issues processing fails
Network unavailable Interrelated messages
processed individually
Connection drops Failure may leave the
Network loses distributed system in an
inconsistent state
messages Messages can’t be
Messages may arrive retried without side
effects
out of order
Sessions

Service Instance Proxy

Channel Session Channel


Reliable Sessions
Assurances

Messages are delivered exactly once, in the same


order as they were sent
Alternatively, you can choose to have them delivered in
order in which they were received
Resilient to
Transport disconnections
SOAP or transport intermediary failures
Features
Connection verification and maintenance
Congestion and flow control
Reliable Sessions
Enabling

Provided on Standard Bindings


netTcpBinding (off by default)
wsHttpBinding (off by default)
wsDualHttpBinding (always on)
Can be added to any custom binding

<bindings>
<customBinding>
<binding configurationName=”ReliabilityHTTP”>
<reliableSession/>
<httpTransport/>
</binding>
</customBinding>
</bindings>
Keeping It Consistent

Atomic Transactions versus Compensation


Trading off coupling and complexity
Atomic Transactions: simpler to develop, negative perf
impact, tighter coupling
Compensation: more complex to develop, better perf,
looser coupling
Both have their place
Choose the right model for the situation
Transactions: Participation
Interface Definition

[ServiceContract]
public interface IMyContract
{
[OperationContract]
[TransactionFlow(TransactionFlowOption.Required)]
bool Transfer1(Account from, Account to, decimal amount);

[OperationContract]
[TransactionFlow(TransactionFlowOption.NotAllowed)]
bool Transfer2(Account from, Account to, decimal amount);

}
Transactions: Interaction
Service Programmer

[BindingRequirements(
TransactionFlowRequirements=RequirementsMode.Require)]
[ServiceBehavior(
TransactionAutoCompleteOnSessionClose = true,
ReleaseServiceInstanceOnTransactionComplete = true)]
public class MyService: IMyContract
{
[OperationBehavior( TransactionScopeRequired = true,
TransactionAutoComplete = true)]
public bool Transfer1(Account from, Account to, decimal amount)
{ ... }
[OperationBehavior( TransactionScopeRequired = true,
TransactionAutoComplete = false)]
public bool Transfer2(Account from, Account to, decimal amount)
{ ...
OperationContext.Current.SetTransactionComplete();
}
}
Transactions: Usage
Client Programmer

TransactionScope transaction;
using (scope = new TransactionScope())
{
proxyForServiceOne.Transfer1(AccountOne, AccountTwo, amount);
proxyForServiceTwo.Transfer1(AccountThree,AccountFour,amount);
UpdateLocalCache(AccountOne, AccountTwo, amount);
scope.Complete();
}
Transactions: Control
Service Administrator
<bindings>
<wsHttpBinding>
<binding configurationName="SampleBinding“
transactionFlow=“true" />
</binding>
</wsHttpBinding>
</bindings>
How Queues Work
Caller Service

Message

Message
Queue Queue
Queues

Increase availability
Mask network or service unavailability
Support scale out
Multiple readers from a single queue
Provide load leveling
Handle average, not peak load
Are a building block for compensating transactions
Reliable, durable messaging to capture distributed
state changes
Need to compensate for errors
How Queues Work
Caller Service

Dead Letter Poison


Queue Queue

Queue Queue
Message Message
Queue Endpoint

<endpoint
address ="net.msmq://MyServer/private$/MyQueue/”
binding="netMsmqBinding"
bindingConfiguration ="MyQueueBinding"
contract="IPurchaseOrder" />
Queues
Failure compensation

Set up compensation services on the


sending
<binding and receiving sides
configurationName="MyQueueBinding“
...
timeToLive="0:2:0"
deadLetterQueue= "net.msmq://MyClient/private/myCustomDLQ"
/>

<endpoint
address ="net.msmq://MyServer/private/MyQueue;poison/”
bindingSectionName="netMsmqBinding"
bindingConfiguration ="MyQueueBinding"
contractType="Queue.IPurchaseOrder" />
Configuring Service Retries
<netMsmqBinding>
<binding configurationName="MyQueueBinding"
msmqAuthenticationMode="None“
msmqProtectionLevel="None"
maxRetries="2"
maxRetryCycles="3"
retryCycleDelay="0:0:10"
rejectAfterLastRetry="false" />
</netMsmqBinding>

1st 3 retry cycles


attempt

To Poison
2 retries 10 Message
seconds Queue
WCF Manageability

Configuration system which allows post-deployment


tuning and control of many aspects of service
Tracing sources provide traces for service internals,
logged messages, activities
Performance counters for key operation, security,
reliability, transaction statistics
WMI Provider allows scriptable query support for all
aspects of running services
Windows Event Log helps with diagnosis of
deployment problems
Configuration Editor and Trace Viewer in the SDK
simplify common IT Pro tasks
Getting .NET 3.0

V1
B1 CTP CTP B2 RCx
RTM

Q2 Q3 Q4 Q1 Q2 Q3 Q4 Q1
2005 2006 2007

Built in to Windows Vista


Available for Windows XP SP2 & Windows
Server 2003 SP1
Release Candidate 1 available from:
http://
WCF Summary

New communication infrastructure for


.NET applications
Interoperable
Flexible
Easy to deploy and manage
Conclusion

.NET 3.0 provides a dramatic set of new


features
Easier coding
More maintainable
More capability
Leverages existing tools and skills
Plugs into Visual Studio 2005
Extension of the base framework

Vous aimerez peut-être aussi