WCF service with netMessagingBinding fails to activate if prefetchCount is greater than zero

Answered WCF service with netMessagingBinding fails to activate if prefetchCount is greater than zero

  • 2012年2月13日 上午 05:03
     
     

    Hi there,

    I'm building a service that uses the AppFabric Service Bus WCF binding (netMessagingBinding). When I use the default configuration, everything works fine; however, the service doesn't process particularly quickly (i.e. even with a large number of pending messages on the queue, only 1 - 2 service instances are created according to the performance counters). To work around this, I tried changing the prefetchCount to a value greater than zero (as suggested here, in the WCF netMessagingBinding config). When I did this, the service no longer activated and the following appeared in the VS debug output window:

    A first chance exception of type 'System.OverflowException' occurred in Microsoft.ServiceBus.DLL
    A first chance exception of type 'System.OverflowException' occurred in mscorlib.dll
    [Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver+ReceiveAsyncResult] IteratorAsyncResult failed to move to the next step due to an exception; System.OverflowException: TimeSpan overflowed because the duration is too long.
       at System.TimeSpan.Interval(Double value, Int32 scale)
       at System.TimeSpan.FromSeconds(Double value)
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageReceiver.ReceiveAsyncResult.<GetAsyncSteps>d__3d.MoveNext()
       at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.MoveNextStep()

    This exception is generated repeatedly until the service is shutdown.

    Any suggestions? Is this a known issue or is my service mis-configured?

    Many thanks,

    James

所有回覆

  • 2012年2月13日 上午 08:33
    版主
     
     

    Hi,

      >> System.OverflowException: TimeSpan overflowed because the duration is too long.

    Could you please provide your configuration or code, so that we can find why merely setting PrefetchCount get result in overflow.

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

  • 2012年2月13日 下午 09:30
     
     

    Here is my system.serviceModel section (excluding the extensions section):

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="serviceBusBehavior">
          <transportClientEndpointBehavior>
            <tokenProvider>
              <sharedSecret issuerName="owner" issuerSecret="##KEY##" />
            </tokenProvider>
          </transportClientEndpointBehavior>
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <bindings>
      <netMessagingBinding>
         <binding name="serviceBusBinding" prefetchCount="10" sessionIdleTimeout="00:01:00">
           <transportSettings batchFlushInterval="00:00:01" />
         </binding>
      </netMessagingBinding>
    </bindings>

    <services>
      <service name="SbPrefetchService.Service1">
        <endpoint address="sb://##NAMESPACE##.servicebus.windows.net/##QUEUE##/" binding="netMessagingBinding" bindingConfiguration="serviceBusBinding" contract="SbPrefetchService.IService1" behaviorConfiguration="serviceBusBehavior" />
        <endpoint address="" binding="basicHttpBinding" contract="SbPrefetchService.IService1" />
      </service>
    </services>

    Thanks!

  • 2012年2月21日 上午 07:25
     
     

    Can you post your sample code? base on the document, it only support single client.

    Enable prefetching if receivers consume messages at a high rate. In low-latency scenarios, enable prefetching if a single client consumes messages from the queue or subscription. If multiple clients are used, set the prefetch count to 0. By doing so, the second client can receive the second message while the first client is still processing the first message.

  • 2012年2月24日 上午 01:23
     
     

    I've uploaded my solution here.

    To repro the problem:

    1. Update the web.config with your SB address and SB owner key.
    2. Start debugging the web application.
    3. Navigate to the service in the web browser to activate it.
    4. View the Visual Studio output window (stream of exceptions, no messages are processed).

    If you set prefetchCount = -1, then it works as expected (I've set it to 10 in the config).

    The solution also includes a test client for sending messages to the SB.

    Thanks!

  • 2012年3月1日 上午 09:16
     
     

    Hi James,

    I can reproduce the same issue as you.

    I will check it further and let you know result.

    Leo Lin

  • 2012年3月7日 上午 01:49
     
     已答覆

    Hi James,

    We confirm this is a known issue. It’s fixed internally and will be included as part of the next Azure SDK update.

    Thanks

    Leo Lin