-
-
Save rogeralsing/d250694198166c3e5b8d to your computer and use it in GitHub Desktop.
This file contains 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
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