Skip to content

Instantly share code, notes, and snippets.

@rogeralsing
Created April 12, 2015 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogeralsing/d250694198166c3e5b8d to your computer and use it in GitHub Desktop.
Save rogeralsing/d250694198166c3e5b8d to your computer and use it in GitHub Desktop.
public async void Process()
{
while(true)
{
var messages = bus.ReceiveBatch(1000,Timespan.FromSeconds(1));
var tasks = new List<Task>();
foreach(var message in messages)
{
//pass relevant message info to actor
//complete the mq message if the actor is done
var task = myConsistentHashRoutedActor.Ask<BusinessAck>(new SomeMessage(message.x,message.y), Timespan.FromSeconds(1)).ContinueWith(t => {
message.Complete();
});
tasks.Add(task);
}
//wait for all tasks to complete before processing more messages
//this could ofc be optimized to continue before all messages are done.
await Task.WhenAll(tasks);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment