WCF Communication Patterns: More than RequestReply - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

WCF Communication Patterns: More than RequestReply

Description:

Real power is in decoupling systems ... WCF s Hidden Power [Bindings] ... Let's bring some coolness into our dev life talk about developer videos and media ... – PowerPoint PPT presentation

Number of Views:679
Avg rating:3.0/5.0
Slides: 33
Provided by: downloadM
Category:

less

Transcript and Presenter's Notes

Title: WCF Communication Patterns: More than RequestReply


1
WCF Communication PatternsMore than
Request-Reply
  • Christian Weyer
  • thinktecture
  • Co-Founder Solution Architect
  • http//www.thinktecture.com/staff/christian
  • christian.weyer_at_thinktecture.com

2
WCF Communication PatternsMore than
Request-Reply
  • Christian Weyer
  • thinktecture
  • Co-Founder Solution Architect
  • http//www.thinktecture.com/staff/christian
  • christian.weyer_at_thinktecture.com

3
What To Expect
  • ABC 101
  • Internals 101
  • MEPs 101
  • Contracts and MEPs
  • Bindings and MEPs
  • Real-World Check

4
ABC 101
5
WCF Birds Eye View
Client
Service
Endpoint
Endpoint
Endpoint
Endpoint
6
WCF Address, Binding, Contract
Service
Client
C
B
A
C
B
A
A
B
C
C
B
A
Address Where?
Contract What?
Binding How?
Endpoint
7
Internals 101
8
WSDL Importer
Service Model Layer
Contract
Contract
WSDL Exporter
Client Code parameters
Service Type parameters
Operation Invoker
Dispatcher Runtime
Parameter Inspector
Parameter Inspector
Client Runtime
Message Formatter
Message Formatter
Operation Selector
Message Inspector
Message Inspector
Channel
Channel Layer
Custom Channel
Channel
Custom Channel
Channel
Custom Channel
Channel
Custom Channel
Transport Channel byte
Transport Channel byte
Encoder
Encoder
Custom Encoder
Custom Encoder
Custom Transport
Custom Transport
Added by configuring the runtime with behaviors
Added by adding binding elements to the binding
9
Layered Extensibility
Service Model Extensibility (local only)
Channel Extensibility (affects the wire)
10
MEPs 101
11
Telephone or answering machine
  • Synchronous vs. asynchronous execution
  • Orthogonal to communication pattern
  • Developers typically choose the way of least
    resistance
  • Synchronous programming is what they are used to
  • Threading, synchronization, callbacks et. al. are
    too cumbersome
  • Real power is in decoupling systems
  • Asynchronous communication in distributed
    solutions can solve a lot of issues but can
    also introduce new ones

12
Message-based Communication
  • Messages travel between communication parties
  • Messages can be grouped into different message
    exchange patterns (MEPs)
  • MEPs can be implemented synchronously or
    asynchronously
  • WCF supports different MEPs
  • One-way
  • Request-reply
  • Duplex
  • WCF MEPs implemented by different kinds of
    channels

13
Channel Shapes
14
Channel Shaping
  • Possible mismatch
  • Physical transport
  • Logical message exchange patterns
  • Channel shapes implemented in transport bindings
  • Express support for MEPs
  • WCF ServiceModel analyzes contract
  • Which channel shapes will be supported?
  • ServiceChannelFactory.BuildChannelFactory and
    DispatcherBuilder.GetSupportedChannelTypes have
    the details

15
Contracts MEPs
16
Contracts Request-Reply
  • Most commonly used MEP
  • It is easy to use and looks natural
  • R/R can be implemented in WCF by several
    approaches
  • Parameter list
  • DataContract
  • MessageContract
  • Message
  • Mind the public face of contracts, i.e. the
    metadata

17
Contracts One-Way
  • O/W operations smell more feasible when
    decoupling is goal
  • No return values, rather void
  • Use IsOneWay property of OperationContract
  • O/W operations can still block
  • Not really fire-and-forget semantics

18
Contracts Duplex
  • Having peer communication parties
  • Blurring the line between client and server
  • Use CallbackContract property of ServiceContract
  • Operations in contracts can be one-way, but need
    no to be
  • If using non-one-way beware of threading issues

19
Contracts Streaming
  • Buffered communication can be very expensive with
    large data
  • WCF offers streamed transfer
  • Contract parameters must have certain shape
  • Use Message, IXmlSerializable or System.IO.Stream
    or derivate as type
  • Use MessageContract
  • Headers will be buffered
  • Body as System.IO.Stream will be streamed
  • Only works with appropriate binding

20
Bindings MEPs
21
WCFs Hidden Power
22
Bindings Request-Reply
  • Almost all out-of-the-box bindings support
    request-reply
  • MSMQ-based bindings do not
  • For all bindings and MEPs
  • Beware of default min/max values on binding
    elements for e.g. message sizes and buffers and
    timeouts
  • Beware of possible throttles on service behavior

23
Bindings One-Way
  • All bindings support one-way operations
  • Use OneWayBindingElement for custom bindings to
    shape channel
  • Performs a message-level shape change
  • Can take a IDuplexSessionChannel or a
    IRequestChannel and expose it as a
    IOutputChannel, or conversely it can take a
    IDuplexSessionChannel or a IReplyChannel and
    expose it as a IInputChannel

24
Bindings Duplex
  • Duplex out-of-the-box
  • netTcp
  • wsDualHttp
  • netNamedPipe
  • netPeerTcp
  • Manual duplex session-less, e.g.

25
Bindings Streaming
  • Enable streaming on the baked-in bindings
  • All standard bindings besides MSMQ-based
  • Enable streaming on the transport binding
    element, e.g.
  • Possible transferMode values
  • Buffered
  • Streamed
  • StreamedRequest
  • StreamedResponse
  • Only transport security and no reliable sessions
    allowed

26
MSMQ transport
  • MSMQ is different always has been
  • Duplex MEP over MSMQ-based binding can be
    achieved by e.g. doing it manually
  • Leverage message headers
  • Access headers through OperationContext in user
    code
  • Access headers through message inspectors in
    ServiceModel extensions
  • Use GUID to correlate messages

27
Real-World Check
  • Common gotchas
  • Nice features, but do I really need them?
  • What about interop, e.g. with Java?
  • Firewalls NATs
  • Deployment of MSMQ
  • Support for mobile devices
  • Not always is WCF the hammer, as not always
    everything is a nail

28
Sample Application YAPOS ?
  • Yet Another Purchase Order Scenario?No, dont
    fear.
  • Lets bring some coolness into our dev life
    talk about developer videos and media
  • Every good developer these days needs to deal
    with online resources and multimedia content
  • MSDN.TV
  • Channel 9
  • Dotnetpro.tv (German)

29
Sample Application Scenario
Reviewer
Media Service
Web Server
User
New Media Service
Message Queue
Message Queue
Upload Service
Web Server
30
(No Transcript)
31
Resources
  • Email Christian Weyer
  • christian.weyer_at_thinktecture.com
  • Weblog Christian Weyer
  • http//blogs.thinktecture.com/cweyer
  • thinktecture
  • http//www.thinktecture.com

32
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com