Created
December 12, 2018 12:34
-
-
Save mikhailshilkov/6565f25f2457a207112792ab8cf45815 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Net; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.WindowsAzure.Storage; | |
using Microsoft.WindowsAzure.Storage.Queue; | |
namespace sendQueue | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
ServicePointManager.UseNagleAlgorithm = false; | |
SendStuff(0, 100000, 50); | |
Console.WriteLine("Done!"); | |
} | |
private static void SendStuff(int min, int max, int parallel) | |
{ | |
var storageAccount = CloudStorageAccount.Parse("redacted"); | |
var queueClient = storageAccount.CreateCloudQueueClient(); | |
var name = "myqueue"; | |
var queue = queueClient.GetQueueReference(name); | |
for (int i = min; i < max / parallel; i++) | |
{ | |
var messages = Enumerable.Range(0, parallel).Select(j => new CloudQueueMessage((i* parallel + j).ToString())); | |
var tasks = messages.Select(queue.AddMessageAsync); | |
Task.WaitAll(tasks.ToArray()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment