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 LoadRequestTest() { var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING, BASE_QUEUE_PATH); var db = manager.Db; var item = db.Find <QueueMessageItem>("select TOP 1 * from queueMessageItems where Started is null"); // no pending items - nothing to do if (item == null) { Console.WriteLine("No pending items... nothing to do."); return; } string reqId = item.Id; // clear out item item = null; // load through manager item = manager.Load(reqId); Assert.IsNotNull(item, manager.ErrorMessage); item.Message = "Updated @ " + DateTime.Now.ToString("t"); item.PercentComplete = 10; Assert.IsTrue(manager.Save(), manager.ErrorMessage); }
public void SubmitRequestsToQueueTest() { var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING, BASE_QUEUE_PATH); int queueCount = 10; bool res = true; for (int i = 0; i < queueCount; i++) { var msg = new QueueMessageItem() { QueueName = "MPWF", Message = "Xml Message #" + i.ToString() + " @ " + DateTime.Now.ToString("t"), Action = "NEWXMLORDER" }; manager.SubmitRequest(msg); res = manager.Save(msg); if (!res) { break; } } }
public void GetNextQueueMessageItemWithAddedItemTest() { using (var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING, BASE_QUEUE_PATH)) { // delete all pending requests int res = manager.Db.ExecuteNonQuery("delete from queuemessageItems where started is null"); Console.WriteLine(res); // delete all queued ids - otherwise no items will match :-) var queue = manager.GetQueue(""); queue.Purge(); // creates sql and msmq items manager.SubmitRequest(messageText: "Next Complete Test " + DateTime.Now.ToString("t")); Assert.IsTrue(manager.Save(), manager.ErrorMessage); } using (var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING, BASE_QUEUE_PATH)) { var item = manager.GetNextQueueMessage(); Assert.IsNotNull(item, manager.ErrorMessage); Console.WriteLine(item.Message); manager.CompleteRequest(item, "Next Complete complete " + DateTime.Now.ToString("t")); Assert.IsTrue(manager.Save(), manager.ErrorMessage); } }
public void SubmitRequestWithPropertiesTest() { var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING, BASE_QUEUE_PATH); manager.SubmitRequest(messageText: "New Entry with Properties"); // add a custom property manager.Properties.Add("Time", DateTime.Now); Assert.IsTrue(manager.Save(), manager.ErrorMessage); }
public void SubmitRequestWithPresetObjectTest() { string xml = "<doc><value>Hello</value></doc>"; var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING,BASE_QUEUE_PATH); var msg = new QueueMessageItem() { QueueName="MPWF", Message = "Xml Message @ " + DateTime.Now.ToString("t"), Action = "NEWXMLORDER", Xml = xml }; manager.SubmitRequest(msg); Assert.IsTrue(manager.Save(), manager.ErrorMessage); }
public void SubmitRequestWithPresetObjectTest() { string xml = "<doc><value>Hello</value></doc>"; var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING, BASE_QUEUE_PATH); var msg = new QueueMessageItem() { QueueName = "MPWF", Message = "Xml Message @ " + DateTime.Now.ToString("t"), Action = "NEWXMLORDER", Xml = xml }; manager.SubmitRequest(msg); Assert.IsTrue(manager.Save(), manager.ErrorMessage); }
public void SubmitRequestsToQueueTest() { var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING,BASE_QUEUE_PATH); int queueCount = 10; bool res = true; for (int i = 0; i < queueCount; i++) { var msg = new QueueMessageItem() { QueueName = "MPWF", Message = "Xml Message #" + i.ToString() + " @ " + DateTime.Now.ToString("t"), Action = "NEWXMLORDER" }; manager.SubmitRequest(msg); res = manager.Save(msg); if (!res) break; } }
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 GetNextQueueMessageItemWithAddedItemTest() { using (var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING,BASE_QUEUE_PATH)) { // delete all pending requests int res = manager.Db.ExecuteNonQuery("delete from queuemessageItems where started is null"); Console.WriteLine(res); // delete all queued ids - otherwise no items will match :-) var queue = manager.GetQueue(""); queue.Purge(); // creates sql and msmq items manager.SubmitRequest(messageText: "Next Complete Test " + DateTime.Now.ToString("t")); Assert.IsTrue(manager.Save(), manager.ErrorMessage); } using (var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING,BASE_QUEUE_PATH)) { var item = manager.GetNextQueueMessage(); Assert.IsNotNull(item, manager.ErrorMessage); Console.WriteLine(item.Message); manager.CompleteRequest(item, "Next Complete complete " + DateTime.Now.ToString("t")); Assert.IsTrue(manager.Save(), manager.ErrorMessage); } }
public void LoadRequestTest() { var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING,BASE_QUEUE_PATH); var db = manager.Db; var item = db.Find<QueueMessageItem>("select TOP 1 * from queueMessageItems where Started is null"); // no pending items - nothing to do if (item == null) { Console.WriteLine("No pending items... nothing to do."); return; } string reqId = item.Id; // clear out item item = null; // load through manager item = manager.Load(reqId); Assert.IsNotNull(item, manager.ErrorMessage); item.Message = "Updated @ " + DateTime.Now.ToString("t"); item.PercentComplete = 10; Assert.IsTrue(manager.Save(), manager.ErrorMessage); }
public void SubmitRequestWithPropertiesTest() { var manager = new QueueMessageManagerSqlMsMq(CONNECTION_STRING,BASE_QUEUE_PATH); manager.SubmitRequest(messageText: "New Entry with Properties"); // add a custom property manager.Properties.Add("Time", DateTime.Now); Assert.IsTrue(manager.Save(), manager.ErrorMessage); }