When to use duplex service?

Well, I know that in a duplex contract, a service can send messages to a client, but I would like to know when it is really useful.

I have a general application that sends a request to a service to retrieve data from a database, insert data ... etc. Also, I need to store about 40 MB files in a database, so I need good performance. For this reason, I would like to use the net.tcp binding with streaming mode, but the problem is that the duplex net.tcp service cannot use the streaming mode.

So, I think I have some options.

1.- Learn if I really need a duplex contract for this kind of application. Perhaps, for example, in a chat application, it makes more sense in a duplex contract, because the server may need to notify the client when the contact is connected ... etc. But in the general client who has access to the database, is a duplication agreement necessary? What operations may require a duplex contract?

2. Another option is not to have a duplex contract, but to implement on the server a non-duplex contract and another separate contract in the client, so when the client connects to the service, the service receives the necessary information to connect to the client service. But, is this a good way to avoid a duplex contract?

3.- Really, for my application, do I need tcp instead of duplex HTTP, which allows streaming? What are the performance benefits of tcp over HTTP?

Thank.

+5
source share
2 answers

Addressing of each point:

1, 2. I think that for your scenario, duplex service is redundant. As you tell yourself, a duplex service is usually convenient when both the client and the service must constantly tell each other what you are doing, getting a lot of data to / from the database does not seem to be a good example of using duplex communication. As for netTcpBindingnot allowing streaming with duplex, you can just return an array of bytes (byte[]) . 40 , , Streaming , ( , ). , : ( ), , , , Stream:

[OperationContract]
Stream RetrieveFile(long _fileId);
[OperationContract]
long SaveFile(Stream _stream);

3. netTcpBinding HTTP-, , , TCP- -, netTcpBinding , . , , , netTcpBinding ( TCP, ..), (LAN), netTcpBinding . wsDualHttpBinding ( : @) , ( PollingDuplexHttpBinding Silverlight) HTTP, .

, , WCF:

http://blog.shutupandcode.net/?p=1085

http://tomasz.janczuk.org/2010/03/comparison-of-http-polling-duplex-and.html

WCF HTTP, , 2 :

http://garfoot.com/blog/2008/06/transferring-large-files-using-wcf/

http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP

, netTcpBinding, , netTcpBinding , HTTP , . 40 . , . , , , , , , . , WCF, ;)

+5

, . , , - .

, , :

  • - X , , . ( ), , , . - .
  • - , , . C, .NET WCF. , .

, / , - ( ), .

WCF , ( ), ( ). .

:

  • , . , , , . , , , .
  • , , . , MS. , . - .
  • , tcp + streamed . TCP , + TCP, HTTP- SOAP. , . .
+6

All Articles