wcf communication patterns more than request reply l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
WCF Communication Patterns: More than Request-Reply PowerPoint Presentation
Download Presentation
WCF Communication Patterns: More than Request-Reply

Loading in 2 Seconds...

play fullscreen
1 / 32

WCF Communication Patterns: More than Request-Reply - PowerPoint PPT Presentation


  • 227 Views
  • Uploaded on

WCF Communication Patterns: More than Request-Reply. Christian Weyer thinktecture Co-Founder & Solution Architect http://www.thinktecture.com/staff/christian christian.weyer@thinktecture.com. WCF Communication Patterns: More than Request-Reply. Christian Weyer thinktecture

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'WCF Communication Patterns: More than Request-Reply' - dai


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
wcf communication patterns more than request reply

WCF Communication Patterns:More than Request-Reply

Christian Weyer

thinktecture

Co-Founder & Solution Architect

http://www.thinktecture.com/staff/christian

christian.weyer@thinktecture.com

wcf communication patterns more than request reply2

WCF Communication Patterns:More than Request-Reply

Christian Weyer

thinktecture

Co-Founder & Solution Architect

http://www.thinktecture.com/staff/christian

christian.weyer@thinktecture.com

what to expect
What To Expect
  • ABC 101
  • Internals 101
  • MEPs 101
  • Contracts and MEPs
  • Bindings and MEPs
  • Real-World Check
wcf bird s eye view
WCF: Bird’s Eye View

Client

Service

Endpoint

Endpoint

Endpoint

Endpoint

wcf address binding contract
WCF: Address, Binding, Contract

Client

Service

A

B

C

A

B

C

C

B

A

A

B

C

Address

Where?

Binding

How?

Contract

What?

Endpoint

slide8

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 Layer

Channel

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

layered extensibility
Layered Extensibility

Client Runtime

Dispatch Runtime

Protocol Channel(s)

Transport Channel

Protocol Channel(s)

Transport Channel

Service Model Extensibility

(local only)

Channel Extensibility

(affects the wire)

telephone or answering machine
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

message based communication
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

channel shapes
Channel Shapes

IOutputChannel

IInputChannel

IRequestChannel

IReplyChannel

IDuplexChannel

IDuplexChannel

channel shaping
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

contracts request reply
[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

contracts one way
[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

contracts duplex
[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

contracts streaming
[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

bindings request reply
[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

bindings one way
[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

bindings duplex
[Bindings]Duplex

Duplex out-of-the-box

netTcp

wsDualHttp

netNamedPipe

netPeerTcp

Manual duplex session-less, e.g.

<compositeDuplex />

<oneWay />

<binaryMessageEncoding />

<httpTransport />

bindings streaming
[Bindings]Streaming

Enable streaming on the baked-in bindings

All standard bindings besides MSMQ-based

Enable streaming on the transport binding element, e.g.

<httpTransport transferMode=„Streamed“ />

Possible transferMode values

Buffered

Streamed

StreamedRequest

StreamedResponse

Only transport security and no reliable sessions allowed

msmq transport
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

real world check
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

sample application yapos
Sample Application: YAPOS ?

Yet Another Purchase Order Scenario?No, don’t fear.

Let’s 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)

sample application scenario
Sample Application Scenario

Reviewer

Media Service

Web Server

User

New Media

Service

Message

Queue

Message

Queue

Upload Service

Web Server

resources
Resources

Email Christian Weyer

christian.weyer@thinktecture.com

Weblog Christian Weyer

http://blogs.thinktecture.com/cweyer

thinktecture

http://www.thinktecture.com