WCF Service Buffer

I am currently working on a WCF service and have a little problem. The service is a survey duplication service. I initiate data transfer through a message sent to the server. Then the server sends large packets of data back through the return channel to the client pretty quickly.

To stop sending messages to the server, report this by stopping. He then sends a message on the callback channel, confirming this, to inform the client.

The problem is that a bunch of data packets are buffered to send to the client callback channel. This causes a long wait for confirmation to return it, because it must wait until all the data passes first.

Is there a way to clear the buffer for the server side callback channel? I don’t need to worry about data loss, I just need to throw it away and immediately send a confirmation message.

+2
source share
1 answer

I'm not sure if this can lead you in the right direction or not ... I have a similar service where, when I look in my Subscribe () method, I can access this:

var context = OperationContext.Current; var sessionId = context.SessionId; var currentClient = context.GetCallbackChannel<IClient>(); context.OutgoingMessageHeaders.Clear(); context.OutgoingMessageProperties.Clear(); 

Now, if you had a way to use the IClient object and to access the context in which you received the IClient instance (allow its context), could the following two statements be executed to do what you want?

 context.OutgoingMessageHeaders.Clear(); context.OutgoingMessageProperties.Clear(); 

Just quick steps from my thoughts. I would like to know if this will fix it or not, for personal information, if nothing else. Could you cache OperationContext as part of a SubscriptionObject that will contain 2 properties, the first of which relates to OperationContext, and the second to your IClient.

+1
source

Source: https://habr.com/ru/post/1416566/


All Articles