This sample demonstrates how to use the Windows Azure Service Bus messages prefetch feature. See the Service Bus documentation for more information about the Service Bus before exploring the samples.
This sample demonstrates how to use the messages prefetch feature upon receive. The sample creates a queue, sends messages to it and receives all messages using 2 receivers one with prefetchCount = 0 (disabled) and the other with prefetCount = 100. For each case, it calculates the time taken to receive and complete all messages and at the end, it prints the difference between both times.
Prerequisites
If you haven't already done so, please read the release notes document that explains how to sign up for a Windows Azure account and how to configure your environment.
Sample Flow
The sample flows in the following manner:
- Sample creates a queue
- A QueueClient is created to send and receive messages.
- The QueueClient sends 1000 messages;
- The PrefetchCount property of the QueueClient is set to 0 (disabled);
- The QueueClient receives all the messages;
- The receive time is calculated: t1.
- Another QueueClient is created to send and receive messages.
- The QueueClient sends 1000 messages;
- The PrefetchCount property of the QueueClient is set to 100;
- The QueueClient receives all the messages;
- The receive time is calculated: t2.
- Time difference is calculated = t1 - t2.
Running the Sample
To run the sample:
- Build the solution in Visual Studio and run the sample project.
- When prompted enter following information:
- ServiceBus namespace;
- ServiceBus issuer name;
- And ServiceBus issuer key.
Expected Output
Please provide the namespace to use: |