Presentation is loading. Please wait.

Presentation is loading. Please wait.

3/25/2017 8:53 AM Windows Communication Foundation (“Indigo”): A Deep Dive Into Extending The Channel Layer Kenny Wolf, Software Development Engineer.

Similar presentations


Presentation on theme: "3/25/2017 8:53 AM Windows Communication Foundation (“Indigo”): A Deep Dive Into Extending The Channel Layer Kenny Wolf, Software Development Engineer."— Presentation transcript:

1 3/25/2017 8:53 AM Windows Communication Foundation (“Indigo”): A Deep Dive Into Extending The Channel Layer Kenny Wolf, Software Development Engineer Yasser Shohoud, Lead Program Manager COM424 Microsoft Corporation ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

2 Channel extensibility is an opportunity for component vendors
What’s in it for you? Enable new transports (e.g. SMTP, UDP) Integrate with other systems (e.g. Java RMI) Implement custom infrastructure protocols Channel extensibility is an opportunity for component vendors

3 Endpoints and Channels
ServiceHost host = new ServiceHost(typeof(MyService)); Uri address = new Uri(“net.tcp://kennyw2/Service/endpoint”); Binding binding = new NetTcpBinding(); Type contract = typeof(IMyContract); host.AddEndpoint(address, binding, contract); host.Open();

4 Channel Types Dispatcher Proxy Protocol Channel(s) Protocol Channel(s)
Transport Channel Transport Channel

5 Layered Extensibility
Service Model Extensibility (local only) Dispatcher Proxy Protocol Channel(s) Protocol Channel(s) Channel Extensibility (affects the wire) Transport Channel Transport Channel

6 Outline Writing a TCP transport Writing a chunking protocol channel
3/25/2017 8:53 AM Outline Writing a TCP transport Writing a chunking protocol channel Wrap up and Q&A This session focuses on writing custom channels Protocol channels Transport channels Channel architecture was covered in previous talks We will recap briefly ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

7 Channel Shapes IOutputChannel IInputChannel IRequestChannel
3/25/2017 8:53 AM Channel Shapes IOutputChannel IInputChannel IRequestChannel IReplyChannel 3 types of Channel Shapes (BEANBAGS) 1. Datagram: Messages are “fire and forget”. (THROW BEANBAG OVER HEAD) This is like sending a postcard in the mail (could get lost). Or like UDP. This is a building block for Messaging since arbitrary protocols can be built on top of it. 2. Request-Response: (THROW BACK AND FORTH BETWEEN KENNY AND YASSER) Common MEP. RPC, browser GETs, etc. 3. Duplex: bi-directional communication. (KEEP THROWING IN RANDOM ORDER) This is like speaking to a co-worker, etc. * Also Session-ful variants of each of these protocols. * Factories can support multiple shapes For Request-Response you get an IRequestContext instead of a Message (this comment should go in later slides though, doesn’t matter for the overview) IDuplexChannel ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

8 Sockets vs. Channels (Client)
3/25/2017 8:53 AM Sockets vs. Channels (Client) Channel Socket new Socket(); socket.Connect(IP, port) CreateChannel(Uri); channel.Open() socket.Send(byte[]) channel.Send(Message) Throws CommunicationException or TimeoutException Throws SocketException socket.Close() channel.Close() Highlight: Addressing differences (IP+port vs. Uri) Unit of data differences (bytes vs. Message) Message is the fundamental unit of data at the Channel Layer. Message has two parts: a body and extensible collection of headers. Access to a header or body is through XmlReader/XmlWriter, as it’s fundamentally Infoset. Channels Send and Receive Messages. Unit of Data Transferred Exception contract Addressing Shutdown Client {0x08, 0xAF, 0x6D, 0xBE, 0xEF, ...} <Envelope><Body>...</Envelope> my.tcp://kennyw2:808/myService/ ( , 808) Service ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

9 Unit of Data Transfer Message  Bytes
3/25/2017 8:53 AM Unit of Data Transfer Message  Bytes MessageEncoder Text, Binary, and MTOM ship with “Indigo” BufferManager Proper tuning can yield large (>10%) performance increases ArraySegment<byte> WriteMessage(Message, maxSize, BufferManager) Message ReadMessage(ArraySegment<byte>, BufferManager) void WriteMessage(Message message, Stream stream) Message ReadMessage(Stream stream, int maxSizeOfHeaders) BufferManager.CreateBufferManager(long maxBufferPoolSize,int maxSize) BufferManager is a Byte pooling abstraction to use with encoders or to buffer data from the network ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

10 Unit of Data Transfer Framing Message Bytes
Need to encapsulate certain information outside of the SOAP message Byte Length of Data Content Type & Uri for Channel Method: 4 byte size, then data my.tcp://kennyw2/a/ text/xml 19 386 8 channel.Open() CreateChannel(“my.tcp://kennyw2/a/”) channel.Send(message)

11 Sockets vs. Channels (Service)
3/25/2017 8:53 AM Sockets vs. Channels (Service) Socket Channel new Socket(); listenSocket.Bind(IP, port); listenSocket.Listen(); BuildChannelListener<T>(Uri); listener.Open(); Socket = listenSocket.Accept() IChannel = listener.AcceptChannel(); socket.Receive(byte[]) Message = channel.Receive() socket.Close() channel.Close() Highlight: Addressing differences (IP+port vs. Uri) Unit of data differences (bytes vs. Message) Sharing Listeners among Base addresses In the PDC bits this is IListenerFactory+IListener InnerChannelListener CanCreateListener CreateListener [SetUri/SetUniqueUri being replaced with parameter to Binding.BuildListenerFactory()] Unit of Data Transferred Addressing Shutdown Accept Client Service ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

12 Building a TCP Transport
3/25/2017 8:53 AM Building a TCP Transport ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

13 Outline Writing a TCP transport Writing a chunking protocol channel
Wrap up and Q&A

14 What We Will Show You 3/25/2017 8:53 AM
©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

15 Managing Inner Channel State
3/25/2017 8:53 AM Managing Inner Channel State Open Open inner channel Wait for pending sends, if any Drain session, if applicable Close inner channel Close As a protocol channel, you will have a lower channel or an inner channel which is the next channel below you in the stack. So when your state changes, you need to manage the state of that inner channel. Code: See region named StateMachine in ChunkingDuplexSessionChannel. OnOpen checks that state is Created then calls Open on input and output channels and then on inner channel. Similarly, OnClose checks that state is Opened then calls Close on output and input channels then on inner channel. Note that ChunkingOutputChannel.OnClose waits for any pending sends. Finally, OnAbort just calls Abort on the output, input and inner channels. Abort Abort inner channel ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

16 Handling Inner Channel Events
3/25/2017 8:53 AM Handling Inner Channel Events Opened Opening Useful for reacting to state transitions when your code is not driving the channel Closing Closed Just as you need to manage the state of your inner channel when your state changes, you also need to react when the state of the inner channel changes on its own. Typically, protocol channels drive their inner channel’s Opening and Closing so you typically don’t need to handle those events. However, you typically need to handle the Faulted event (which indicates the inner channel has fauled) and either recover from the fault or fault your protocol channel. Faulted When inner channel faults, your channel should recover or fault ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

17 Message Message is the unit of I/O in Indigo Message Headers
3/25/2017 8:53 AM Message Message is the unit of I/O in Indigo Based on XML InfoSet Consists of headers and body Message Headers Buffered, random access collection Used to implement infrastructure protocols Message Body Forward-only cursor Used to carry application data As you may have seen in Don’t talk yesterday, Message is the fundamental unit of I/O in Indigo. It is based on the XML infoset and consists of headers and body. Headers are represented in a buffered, randomly accessible collection and typically used for infrastructure protocols. Body on the other hand is represented as a forward only/read only cursor and typically used to carry application data. ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

18 Working With Message Reading body content
Creating messages using BodyWriter Reading and writing headers Creating messages using XmlDictionaryReader Custom messages

19 Configuring Channels Binding Element Configuration
3/25/2017 8:53 AM Configuring Channels Binding Element Configuration ChunkingBindingElement App Code Properties Chunking Configuration Section Policy Import Can be exposed to Config, Policy, or directly to Code This slide is all about binding elements as builders 2) NOTE: Bindings are not thread-safe, though the runtime objects (that they build) are WS-Policy .config ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

20 Configuring Channels Custom Behaviors
3/25/2017 8:53 AM Configuring Channels Custom Behaviors Custom Behavior BindingParameters BindingElement ChannelFactory ChannelListener ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

21 Using The Chunking Channel
3/25/2017 8:53 AM Using The Chunking Channel ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

22 Please fill out the evaluation We want to know what you think!
Key Take Aways Write custom channels when you need to Change what goes on the wire Integrate with arbitrary systems Enable new transports Channel extensibility is an opportunity for component vendors Please fill out the evaluation We want to know what you think!

23 Community Resources At PDC After PDC
3/25/2017 8:53 AM Community Resources At PDC COM429: A Deep Dive into Extending the Service Model Layer (Fri 10:30am) COM413: IIS and Windows Communication Foundation (“Indigo”): Hosting Services (Fri 1pm) Labs: COMHOL29 Ask The Experts table: Extending WCF COM Track lounge: We’ll be there Thu 5-6pm, Fri 8:30-noon After PDC If you missed this related session, watch it on the DVD COM424: WCF: A Deep Dive into Extending the Channel Layer MSDN dev center: MSDN Forum: Windows Communication Foundation ("Indigo") Channel 9 tag: ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

24 © 2005 Microsoft Corporation. All rights reserved.
3/25/2017 8:53 AM © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. ©2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Download ppt "3/25/2017 8:53 AM Windows Communication Foundation (“Indigo”): A Deep Dive Into Extending The Channel Layer Kenny Wolf, Software Development Engineer."

Similar presentations


Ads by Google