static void Main(string[] args) { var workerConfigurationManager = new WorkerConfigurationManager(); var workerConfiguration = workerConfigurationManager.GetWorkerConfiguration(); var connectionString = workerConfiguration.ConnectionString; var queueName = workerConfiguration.QueueName; var client = QueueClient.CreateFromConnectionString(connectionString, queueName); var orderList = new List <BrokeredMessage>(); var stopwatch = Stopwatch.StartNew(); for (int i = 0; i < 250; i++) { var order = new Order { CreationDate = DateTime.UtcNow, OrderNumber = Guid.NewGuid().ToString(), CustomerId = Guid.NewGuid().ToString(), SalesStatus = SalesStatus.Sold }; var jsonContent = JsonConvert.SerializeObject(order); var message = new BrokeredMessage(jsonContent); orderList.Add(message); } client.SendBatch(orderList); Console.WriteLine($"Finished, took {stopwatch.ElapsedMilliseconds} ms"); }
static void Main(string[] args) { var workerConfigurationManager = new WorkerConfigurationManager(); var workerConfiguration = workerConfigurationManager.GetWorkerConfiguration(); var connectionString = workerConfiguration.ConnectionString; var queueName = workerConfiguration.QueueName; var deadLetterQueueName = QueueClient.FormatDeadLetterPath(queueName); var client = QueueClient.CreateFromConnectionString(connectionString, queueName); client.OnMessage(message => { Console.WriteLine($"Message body: {message.GetBody<String>()}"); Console.WriteLine($"Message id: {message.MessageId}"); }); //RetrieveLoop(client); //PeekMessages(client, stopwatch); Console.ReadLine(); }