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)
This exception is generated repeatedly until the service is shutdown.
Any suggestions? Is this a known issue or is my service mis-configured?
>> 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.
Here is my system.serviceModel section (excluding the extensions section):<behaviors>
<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 -->
<serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>
<sharedSecret issuerName="owner" issuerSecret="##KEY##" />
<binding name="serviceBusBinding" prefetchCount="10" sessionIdleTimeout="00:01:00">
<transportSettings batchFlushInterval="00:00:01" />
<endpoint address="sb://##NAMESPACE##.servicebus.windows.net/##QUEUE##/" binding="netMessagingBinding" bindingConfiguration="serviceBusBinding" contract="SbPrefetchService.IService1" behaviorConfiguration="serviceBusBehavior" />
<endpoint address="" binding="basicHttpBinding" contract="SbPrefetchService.IService1" />
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.
I've uploaded my solution here.
To repro the problem:
- Update the web.config with your SB address and SB owner key.
- Start debugging the web application.
- Navigate to the service in the web browser to activate it.
- 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.
We confirm this is a known issue. It’s fixed internally and will be included as part of the next Azure SDK update.