Created
October 9, 2014 06:14
-
-
Save abishekrsrikaanth/3dd0280b8869e10eb2b8 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
// ========================================================= | |
// Iron.io MQ | |
// ========================================================= | |
IronMqRestClient ironMq = IronSharp.IronMQ.Client.New(); | |
//// Get a Queue object | |
QueueClient queue = ironMq.Queue("my_queue"); | |
QueueInfo info = queue.Info(); | |
//MessageBox.Show(queue.); | |
// Put a message on the queue | |
string messageId = @queue.Post(new QueueMessage("Hello World")); | |
//Console.WriteLine(messageId); | |
//Get a message | |
MessageCollection msg = queue.Get(n: 30, timeout: 60); | |
List<QueueMessage> messageColl = msg.Messages; | |
foreach (var item in messageColl) | |
{ | |
MessageBox.Show(item.Body); | |
bool deleted = item.Delete(); | |
MessageBox.Show(String.Format("Deleted = {0}", deleted)); | |
} | |
// Post several messages | |
queue.Post(new[] { "Hello", "world" }); | |
// Post several messages | |
var payload1 = new | |
{ | |
message = "hello, my name is Iron.io 1" | |
}; | |
var payload2 = new | |
{ | |
message = "hello, my name is Iron.io 2" | |
}; | |
var payload3 = new | |
{ | |
message = "hello, my name is Iron.io 3" | |
}; | |
MessageIdCollection queuedUp = queue.Post(new[] { payload1, payload2, payload3 }); | |
Console.WriteLine(queuedUp.Ids.ToString()); | |
QueueMessage next; | |
while (queue.Read(out next)) | |
{ | |
Console.WriteLine(next.Body); | |
Console.WriteLine(next.Delete()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment