2013-11-28 5 views
7

서비스 버스 2.1을 사용하고 있습니다. Windows Server의 경우 비동기 적으로 메시지를받는 방법이 있습니다.서비스 버스 2.1 Windows 서버의 경우 - TimeOutException on EndReceive 메서드

내 방법의 본문은 다음과 같습니다

나는 버전 2.1에 dll을 Microsoft.ServiceBus을 업데이트 한 이후
var waitTimeout = TimeSpan.FromSeconds(10); 

     // Declare an action acting as a callback whenever a message arrives on a queue. 
     AsyncCallback completeReceive = null; 

     // Declare an action acting as a callback whenever a non-transient exception occurs while receiving or processing messages. 
     Action<Exception> recoverReceive = null; 

     // Declare an action responsible for the core operations in the message receive loop. 
     Action receiveMessage =() => 
     { 
      // Use a retry policy to execute the Receive action in an asynchronous and reliable fashion. 
      retryPolicy.ExecuteAction(
       (cb) => messageReceiver.BeginReceive(waitTimeout, cb, null), 
       (ar) => 
        { 
         // Make sure we are not told to stop receiving while we were waiting for a new message. 
         if (!cts.IsCancellationRequested) 
         { 
          // Complete the asynchronous operation. This may throw an exception that will be handled internally by retry policy. 
          BrokeredMessage msg = messageReceiver.EndReceive(ar); 

          // Check if we actually received any messages. 
          if (msg != null) 
          { 
           // Make sure we are not told to stop receiving while we were waiting for a new message. 
           if (!cts.IsCancellationRequested) 
           { 
            try 
            { 
             // Process the received message. 
             processMessage(msg); 

             // With PeekLock mode, we should mark the processed message as completed. 
             if (messageReceiver.Mode == ReceiveMode.PeekLock) 
             { 
              // Mark brokered message as completed at which point it's removed from the queue. 
              msg.SafeComplete(); 
             } 
            } 
            catch 
            { 
             // With PeekLock mode, we should mark the failed message as abandoned. 
             if (messageReceiver.Mode == ReceiveMode.PeekLock) 
             { 
              // Abandons a brokered message. This will cause Service Bus to unlock the message and make it available 
              // to be received again, either by the same consumer or by another completing consumer. 
              msg.SafeAbandon(); 
             } 

             // Re-throw the exception so that we can report it in the fault handler. 
             throw; 
            } 
            finally 
            { 
             // Ensure that any resources allocated by a BrokeredMessage instance are released. 
             msg.Dispose(); 
            } 
           } 
           else 
           { 
            // If we were told to stop processing, the current message needs to be unlocked and return back to the queue. 
            if (messageReceiver.Mode == ReceiveMode.PeekLock) 
            { 
             msg.SafeAbandon(); 
            } 
           } 
          } 
         } 

         // Invoke a custom callback method to indicate that we have completed an iteration in the message receive loop. 
         completeReceive(ar); 
        }, 
       () => 
        { 

        }, 
       (ex) => 
       { 
        // Invoke a custom action to indicate that we have encountered an exception and 
        // need further decision as to whether to continue receiving messages. 
        recoverReceive(ex); 
       }); 
     }; 

     // Initialize a custom action acting as a callback whenever a message arrives on a queue. 
     completeReceive = (ar) => 
     { 
      if (!cts.IsCancellationRequested) 
      { 
       // Continue receiving and processing new messages until we are told to stop. 
       receiveMessage(); 
      } 
     }; 

     // Initialize a custom action acting as a callback whenever a non-transient exception occurs while receiving or processing messages. 
     recoverReceive = (ex) => 
     { 
      if (!cts.IsCancellationRequested) 
      { 
       // Continue receiving and processing new messages until we are told to stop regardless of any exceptions. 
       receiveMessage(); 
      } 
     }; 

     // Start receiving messages asynchronously. 
     receiveMessage(); 

, 나는 모든 초 두 가지 예외가 (필자는 버전 1.8 및 2.0을 사용하기 전의) :

형의 첫 번째 예외 'System.ServiceModel.FaultException`1가'Microsoft.ServiceBus.dll 형 'System.TimeoutException'의 첫 번째 예외가 발생 Microsoft.ServiceBus.dll

발생한예외를 제기 방법은 다음과 같습니다 'EndReceive'와 Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.ThrowIfFaultMessage (메시지 wcfMessage는)

나는 인터넷에 있지만 대답없는 몇 가지 게시물을 보았다. 누군가 이미이 문제가 발생 했습니까?

+0

내 WSB 응용 프로그램을 디버깅하는 동안 동일한 문제가 발생합니다. –

답변

1

버전 2.05의 Servicebus 라이브러리에서 동일한 문제가 발생했습니다. 3.0으로 업데이트하고 문제를 해결했습니다.