0
我需要將我們的服務總線nuget包升級到3.2.2(認爲偶處理器主機需要它),但我總是將我們的服務總線項目lib保留在2.8.2。這主要是由於BeginReceive()和EndReceive()看起來已被刪除。是否有任何理由或反正我可以很容易地轉換這個Azure服務總線3.2.2 BeginReceive()
public void StartReceiving(RecieverCallback callback, TimeSpan waittime, object state = null)
{
this._recieverCallback = callback;
_queueClient = this.MessagingFactory.CreateQueueClient(QueueName, ReceiveMode);
// make initial async call
_asyncresult = _queueClient.BeginReceive(waittime, ReceiveDone, _queueClient);
}
public void ReceiveDone(IAsyncResult result)
{
if (result != null)
{
try
{
var tmpClient = result.AsyncState as QueueClient;
var brokeredMessage = tmpClient.EndReceive(result);
if (brokeredMessage != null)
{
if (ReceiveMode == ReceiveMode.PeekLock)
{
brokeredMessage.Complete();
}
var tmpMessage = brokeredMessage.GetBody<T>();
ProcessMessageProperties(tmpMessage, brokeredMessage);
_recieverCallback(tmpMessage);
}
}
catch (Exception ex)
{
_logger.Fatal("ReceiveDone: {0}", ex.Message);
Console.WriteLine(ex.Message);
}
}
// do recieve for next message
_asyncresult = _queueClient.BeginReceive(ReceiveDone, _queueClient);
}
下圖顯示了,如果我升級servicebus 3.2.2,我相信這將解決原來的錯誤會發生什麼(程序運行3.2.2,LIB項目運行2.8.x)