public void SubmitRequestTest() { var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING, BASE_QUEUE_PATH); string imageId = "10"; // Create a message object // item contains many properties for pushing // values back and forth as well as a few message fields var item = manager.CreateItem(); item.Action = "PRINTIMAGE"; item.TextInput = imageId; item.Message = "Print Image operation started at " + DateTime.Now.ToString(); item.PercentComplete = 10; // *** you can also serialize objects directly into the Xml property // manager.Serialization.SerializeToXml(SomeObjectToSerialize); // add an arbitrary custom properties - serialized to Xml manager.Properties.Add("Time", DateTime.Now); manager.Properties.Add("User", "ricks"); // Set the message status and timestamps as submitted manager.SubmitRequest(item); // actually save the queue message to disk Assert.IsTrue(manager.Save(), manager.ErrorMessage); }
public void SubmitRequestTest() { var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING,BASE_QUEUE_PATH); string imageId = "10"; // Create a message object // item contains many properties for pushing // values back and forth as well as a few message fields var item = manager.CreateItem(); item.Action = "PRINTIMAGE"; item.TextInput = imageId; item.Message = "Print Image operation started at " + DateTime.Now.ToString(); item.PercentComplete = 10; // *** you can also serialize objects directly into the Xml property // manager.Serialization.SerializeToXml(SomeObjectToSerialize); // add an arbitrary custom properties - serialized to Xml manager.Properties.Add("Time", DateTime.Now); manager.Properties.Add("User", "ricks"); // Set the message status and timestamps as submitted manager.SubmitRequest(item); // actually save the queue message to disk Assert.IsTrue(manager.Save(), manager.ErrorMessage); }
public void ScaleRetrievalTest() { string queueName = "Queue1"; var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING, BASE_QUEUE_PATH); manager.Db.ExecuteNonQuery("delete from queuemessageitems"); manager.GetQueue(queueName).Purge(); var sw = new Stopwatch(); sw.Start(); for (int i = 0; i < 40000; i++) { string imageId = "10"; // Create a message object // item contains many properties for pushing // values back and forth as well as a few message fields var item = manager.CreateItem(); item.QueueName = queueName; item.TextInput = DataUtils.GenerateUniqueId(15); // Set the message status and timestamps as submitted manager.SubmitRequest(item, autoSave: true); } Console.WriteLine("Insert time: " + sw.ElapsedMilliseconds); IdList = new List <string>(); IdErrors = new List <string>(); for (int i = 0; i < 20; i++) { var thread = new Thread(ProcessGetNextItem); thread.Start(); } //Task.Run(() => //{ // for (int i = 0; i < 100; i++) // { // manager = new QueueMessageManagerSql(); // string imageId = "10"; // // Create a message object // // item contains many properties for pushing // // values back and forth as well as a few message fields // var item = manager.CreateItem(); // item.QueueName = "Queue1"; // item.TextInput = DataUtils.GenerateUniqueId(15); // // Set the message status and timestamps as submitted // manager.SubmitRequest(item, autoSave: true); // } // Thread.Sleep(60); //}); for (int i = 0; i < 500; i++) { if (CancelProcessing) { break; } string imageId = "10"; // Create a message object // item contains many properties for pushing // values back and forth as well as a few message fields var item = manager.CreateItem(); item.QueueName = queueName; item.TextInput = DataUtils.GenerateUniqueId(15); // Set the message status and timestamps as submitted manager.SubmitRequest(item, autoSave: true); Thread.Sleep(4); } Console.WriteLine("Waiting for 5 seconds"); Thread.Sleep(5000); CancelProcessing = true; Thread.Sleep(100); Console.WriteLine("Done"); Console.WriteLine("Items processed: " + IdList.Count); var grouped = IdList.GroupBy(s => s); Console.WriteLine("Unique Count: " + grouped.Count()); foreach (var error in IdErrors) { Console.WriteLine(" " + error); } }
public void ScaleRetrievalTest() { string queueName = "Queue1"; var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING,BASE_QUEUE_PATH); manager.Db.ExecuteNonQuery("delete from queuemessageitems"); manager.GetQueue(queueName).Purge(); var sw = new Stopwatch(); sw.Start(); for (int i = 0; i < 40000; i++) { string imageId = "10"; // Create a message object // item contains many properties for pushing // values back and forth as well as a few message fields var item = manager.CreateItem(); item.QueueName = queueName; item.TextInput = DataUtils.GenerateUniqueId(15); // Set the message status and timestamps as submitted manager.SubmitRequest(item,autoSave: true); } Console.WriteLine("Insert time: " + sw.ElapsedMilliseconds); IdList = new List<string>(); IdErrors = new List<string>(); for (int i = 0; i < 20; i++) { var thread = new Thread(ProcessGetNextItem); thread.Start(); } //Task.Run(() => //{ // for (int i = 0; i < 100; i++) // { // manager = new QueueMessageManagerSql(); // string imageId = "10"; // // Create a message object // // item contains many properties for pushing // // values back and forth as well as a few message fields // var item = manager.CreateItem(); // item.QueueName = "Queue1"; // item.TextInput = DataUtils.GenerateUniqueId(15); // // Set the message status and timestamps as submitted // manager.SubmitRequest(item, autoSave: true); // } // Thread.Sleep(60); //}); for (int i = 0; i < 500; i++) { if (CancelProcessing) break; string imageId = "10"; // Create a message object // item contains many properties for pushing // values back and forth as well as a few message fields var item = manager.CreateItem(); item.QueueName = queueName; item.TextInput = DataUtils.GenerateUniqueId(15); // Set the message status and timestamps as submitted manager.SubmitRequest(item, autoSave: true); Thread.Sleep(4); } Console.WriteLine("Waiting for 5 seconds"); Thread.Sleep(5000); CancelProcessing = true; Thread.Sleep(100); Console.WriteLine("Done"); Console.WriteLine("Items processed: " + IdList.Count); var grouped = IdList.GroupBy(s => s); Console.WriteLine("Unique Count: " + grouped.Count()); foreach (var error in IdErrors) Console.WriteLine(" " + error); }