We need to transfer data from one location to other
location. If data transfer is taking place through WCF service, message size
will play major role in performance of the data transfer. Based on the size and
other condition of the data transfer, WCF supports two modes for transferring
messages
When the
client and the service exchange messages, these messages are buffered on the
receiving end and delivered only once the entire message has been received.
This is true whether it is the client sending a message to the service or the
service returning a message to the client.
As a result, when the client calls the service, the service is invoked only after the client's message has been received in its entirety; likewise, the client is unblocked only once the returned message with the results of the invocation has been received in its entirety.
When
client and Service exchange message using Streaming transfer mode, receiver can
start processing the message before it is completely delivered. Streamed
transfers can improve the scalability of a service by eliminating the requirement
for large memory buffers. If you want to transfer large message, streaming is
the best method.
In this
mode of configuration, message send from client to service will be streamed
In this
mode of configuration, message send from service to client will be streamed.
Buffer
transfer
As a result, when the client calls the service, the service is invoked only after the client's message has been received in its entirety; likewise, the client is unblocked only once the returned message with the results of the invocation has been received in its entirety.
Stream
transfer
Stream
Request
Stream
Response
Configuration
<system.serviceModel>
<services >
<service behaviorConfiguration="ServiceBehavior” name="MyService">
<endpoint address="" binding="netTcpBinding"
binding Configuration="MyService. NetTcpBinding" contract="IMyService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true "/>
</behavior>
</serviceBehaviors>
</behaviors>
<Bindings >
<NetTcpBinding>
<binding name="MyService. NetTcpBinding"
Transfer Mode="Buffered" close Timeout ="0:01:00" open Timeout="0:01:00"></binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
Differences
between Buffered and Streamed Transfers
Buffered
|
Streamed
|
Target can process the message once it is completely
received.
|
Target can start processing the data when it is
partially received
|
Performance will be good when message size is small
|
Performance will be good when message size is
larger(more than 64K)
|
Native channel shape is IDuplexSessionChannel
|
Native channels are IRequestChannel and IReplyChannel
|
No comments:
Post a Comment