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

    Question

  • 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

    Monday, February 13, 2012 5:03 AM

Answers

  • 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

    • Proposed as answer by Jian SL-MSFT Wednesday, March 07, 2012 1:49 AM
    • Marked as answer by James Carpinter Wednesday, March 07, 2012 3:06 AM
    Wednesday, March 07, 2012 1:49 AM

All replies

  • 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

    Monday, February 13, 2012 8:33 AM
  • 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!

    Monday, February 13, 2012 9:30 PM
  • 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.

    Tuesday, February 21, 2012 7:25 AM
  • 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!

    Friday, February 24, 2012 1:23 AM
  • Hi James,

    I can reproduce the same issue as you.

    I will check it further and let you know result.

    Leo Lin

    Thursday, March 01, 2012 9:16 AM
  • 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

    • Proposed as answer by Jian SL-MSFT Wednesday, March 07, 2012 1:49 AM
    • Marked as answer by James Carpinter Wednesday, March 07, 2012 3:06 AM
    Wednesday, March 07, 2012 1:49 AM