public static void Main() { System.DateTime timeStart = DateTime.UtcNow; var conn = new RabbitMQConnection("amqp://localhost"); var receiveChannel = new ReceiveChannel <int>(conn); receiveChannel.StartAsync(receiveFunc: async message => { await Task.Delay(1); Console.WriteLine(" Try to [x] Received {0}", message); //try //{ System.DateTime timeNow = DateTime.UtcNow; TimeSpan timeCount = timeNow - timeStart; if (timeCount.TotalMilliseconds < 20000) { //var x = 1 / (timeCount.Seconds - timeCount.Seconds); //Console.WriteLine(x); throw new Exception("Fail...."); } Console.WriteLine(" [x] Received {0}", message); //} //catch (Exception e) //{ // System.Console.WriteLine(e.Message + message); //} }); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); }
public static void Main() { System.DateTime timeStart = DateTime.UtcNow; var conn = new RabbitMQConnection("amqp://localhost"); var receiveChannel = new ReceiveChannel <int>(conn); Console.WriteLine(" Ready to go! "); receiveChannel.StartAsync(receiveFunc: async message => { Console.WriteLine(" Try to [x] Received {0}", message); await Task.Delay(1); //try //{ throw new Exception("Fail...."); Console.WriteLine(" [x] Received {0}", message); //} //catch (Exception e) //{ // System.Console.WriteLine(e.Message + message); // Console.WriteLine(" Fail to handle [x] Received {0}", message); //} }); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); }