Hi,
I am developing code to send messages and receive responses via service bus. Messages and responses are paired via a SesionID.
I am trying to understand the various timeouts that are available
My code (first draft) looks like this:
public async Task<TResponse> SendMessageAsync(TMessage message) { // send request message var msg = CreateRequestMessage(message); _requestClient.SendAsync(msg); var receiver = await _responseClient.AcceptMessageSessionAsync(msg.ReplyToSessionId, TimeSpan.FromMilliseconds(TimeoutMs)).ConfigureAwait(false); try { // receive response message BrokeredMessage receivedMessage = await receiver.ReceiveAsync(TimeSpan.FromMilliseconds(TimeoutMs)).ConfigureAwait(false); if (receivedMessage != null) { var body = receivedMessage.GetBody<Stream>(); return _serializer.DeserializeObject<TResponse>(new StreamReader(body, true).ReadToEnd()); } else { throw new TimeoutException(); } } finally { receiver.Close(); } }
I am testing all my assumptions within the code and am trying to figure out the effect of the serverWaitTime parameter within the AcceptMessageSessionAsync call.
I cant figure it out and the docs are unclear (at least to me ;-). Whatever the value (even TimeSpan.FromTicks(1)) the call returns a MessageSession immediately. No nulls, no TimeoutException.
Only the serverWaitTime on ReceiveAsync seems to make a difference.
Am I missing something? Can someone please explain the serverWaitTime parameter in the AcceptMessageSessionAsync method.
Thanks,
M