public static void RunLoop(IProducerMethodQueue queue, Func <IAdditionalMessageData> expiredDataInstant, Func <IAdditionalMessageData> expiredDataFuture) { var keepRunning = true; while (keepRunning) { Console.WriteLine(@"To test heartbeat recovery, force kill your consumer after starting to process record(s) To test rollbacks, cancel the consumer by pressing any button. Easier to test with longer running jobs. Sync a) Send 1 static job b) Send 1 dynamic job Async c) Send 1 static job d) Send 1 dynamic job q) Quit"); var key = char.ToLower(Console.ReadKey(true).KeyChar); switch (key) { case 'a': HandleResults.Handle(RunStatic(queue, 1, expiredDataFuture), Log.Logger); break; case 'b': HandleResults.Handle(RunDynamic(queue, 1, expiredDataFuture), Log.Logger); break; case 'c': HandleResults.Handle(RunStaticAsync(queue, 1, expiredDataFuture).Result, Log.Logger); break; case 'd': HandleResults.Handle(RunDynamicAsync(queue, 1, expiredDataFuture).Result, Log.Logger); break; case 'q': Console.WriteLine("Quitting"); keepRunning = false; break; } } }
public static void RunLoop(IProducerQueue<SimpleMessage> queue, Func<IAdditionalMessageData> expiredDataInstant, Func<IAdditionalMessageData> expiredDataFuture, Func<int, IAdditionalMessageData> delayProcessing) { var keepRunning = true; while (keepRunning) { Console.WriteLine(@"To test heartbeat recovery, force kill your consumer after starting to process record(s) To test rollbacks, cancel the consumer by pressing any button. Easier to test with longer running jobs. Sync a) Send 10 jobs b) Send 500 jobs c) Send 1000 jobs d) Send 1 job with 20 second processing time e) Send 1 job with 60 second processing time f) Send 100 random jobs g) Test error h) Test retry-able error and finish after some retries i) Test retry-able error and fail after some retries j) Test expire Async k) Send 10 jobs l) Send 500 jobs m) Send 1000 jobs n) Send 1 job with 20 second processing time o) Send 1 job with 60 second processing time p) Send 100 random jobs r) Test error s) Test retry-able error and finish after some retries t) Test retry-able error and fail after some retries u) Test expire Batch v) Send 100 random jobs w) Send 1000 random jobs x) Send Async 100 random jobs y) Send Async 1000 random jobs Long Running z) Send 1 job with a 600 second processing time Delayed Processing 1) Send 1 job with a 10 second processing delay 2) Send 10 jobs with a 30 second processing delay q) Quit"); var key = char.ToLower(Console.ReadKey(true).KeyChar); switch (key) { case 'a': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessage(10, 500, 1000), expiredDataFuture), Log.Logger); break; case 'b': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessage(100, 500, 500), expiredDataFuture), Log.Logger); break; case 'c': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessage(1000, 100, 50), expiredDataFuture), Log.Logger); break; case 'd': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessage(1, 20000, 100000), expiredDataFuture), Log.Logger); break; case 'e': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessage(1, 60000, 10), expiredDataFuture), Log.Logger); break; case 'f': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessageRandom(100), expiredDataFuture), Log.Logger); break; case 'g': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessageError(1000, 0), expiredDataFuture), Log.Logger); break; case 'h': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessageRetryError(1000, false), expiredDataFuture), Log.Logger); break; case 'i': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessageRetryError(1000, true), expiredDataFuture), Log.Logger); break; case 'j': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleExpiredMessage(), expiredDataInstant.Invoke()), Log.Logger); break; case 'z': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessage(1, 600000, 10), expiredDataFuture), Log.Logger); break; //async case 'k': HandleResults.Handle(RunProducer.RunAsync(queue, Messages.CreateSimpleMessage(10, 500, 1000), expiredDataFuture).Result, Log.Logger); break; case 'l': HandleResults.Handle(RunProducer.RunAsync(queue, Messages.CreateSimpleMessage(100, 500, 500), expiredDataFuture).Result, Log.Logger); break; case 'm': HandleResults.Handle(RunProducer.RunAsync(queue, Messages.CreateSimpleMessage(1000, 100, 50), expiredDataFuture).Result, Log.Logger); break; case 'n': HandleResults.Handle(RunProducer.RunAsync(queue, Messages.CreateSimpleMessage(1, 20000, 100000), expiredDataFuture).Result, Log.Logger); break; case 'o': HandleResults.Handle(RunProducer.RunAsync(queue, Messages.CreateSimpleMessage(1, 60000, 10), expiredDataFuture).Result, Log.Logger); break; case 'p': HandleResults.Handle(RunProducer.RunAsync(queue, Messages.CreateSimpleMessageRandom(100), expiredDataFuture).Result, Log.Logger); break; case 'r': HandleResults.Handle(RunProducer.RunAsync(queue, Messages.CreateSimpleMessageError(1000, 0), expiredDataFuture).Result, Log.Logger); break; case 's': HandleResults.Handle(RunProducer.RunAsync(queue, Messages.CreateSimpleMessageRetryError(1000, false), expiredDataFuture).Result, Log.Logger); break; case 't': HandleResults.Handle(RunProducer.RunAsync(queue, Messages.CreateSimpleMessageRetryError(1000, true), expiredDataFuture).Result, Log.Logger); break; case 'u': HandleResults.Handle(RunProducer.RunAsync(queue, Messages.CreateSimpleExpiredMessage(), expiredDataInstant.Invoke()).Result, Log.Logger); break; //batch case 'v': HandleResults.Handle(RunProducer.RunBatch(queue, Messages.CreateSimpleMessageRandomList(100), expiredDataFuture), Log.Logger); break; case 'w': HandleResults.Handle(RunProducer.RunBatch(queue, Messages.CreateSimpleMessageRandomList(1000), expiredDataFuture), Log.Logger); break; case 'x': HandleResults.Handle(RunProducer.RunBatchAsync(queue, Messages.CreateSimpleMessageRandomList(100), expiredDataFuture).Result, Log.Logger); break; case 'y': HandleResults.Handle(RunProducer.RunBatchAsync(queue, Messages.CreateSimpleMessageRandomList(1000), expiredDataFuture).Result, Log.Logger); break; case '1': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessage(1, 500, 1000), () => delayProcessing(10)), Log.Logger); break; case '2': HandleResults.Handle(RunProducer.Run(queue, Messages.CreateSimpleMessage(10, 500, 1000), () => delayProcessing(30)), Log.Logger); break; case 'q': Console.WriteLine("Quitting"); keepRunning = false; break; } } }