WCF Note10(Message Pattern)

来源:互联网 发布:杭州软通动力骗局 知乎 编辑:程序博客网 时间:2024/04/29 12:19

Classic Message Exchange Pattern (MEP):

  1. Request/reply
  2. One-way
  3. Duplex or callbacks
Transformed Pattern : Publish and subscribe

One Way Scenarios:

1. Fire-and-forget

e.g.: Logging

2. Polling

         e.g.: able to make another request to get the previous request status 

3. Duplex 

e.g.: two ways communication,  with call back function, Butbe aware of concurrency issue

Note: Duplex required two ways communication e.g. WSDualHttpBinding

 Code sample: service contract + callback contract 

Server Side: 

Client Side:

Sample: Publisher/Subscriber


Large Message

  1. MTOM: reduces the overhead of binary data transfer: ( help with parsing and sizing transfer)
    1. Remove base64 
    2.  <wsHttpBinding>        <binding name="WsHttpMtomBinding" messageEncoding="Mtom" maxReceivedMessageSize="500000"/><readerQuotas maxArrayLength=”500000"/>    </wsHttpBinding>

  2. Streaming (helping reduce memory usage)
    1. <basicHttpBinding><binding name="basicHttpStreaming"transferMode="Streamed"/></basicHttpBinding>

    2. [OperationContract]
   Stream LoadData()
  1. Chunking message into the small piece
Tool:  TcpTrace

原创粉丝点击