1. 程式人生 > 其它 >[ES] Result window is too large, from + size must be less than or equal to: [10000] but was [10010].

[ES] Result window is too large, from + size must be less than or equal to: [10000] but was [10010].

之前的公司一直是使用的資料庫做佇列,比如要發的各種郵件資訊都會寫到對應的表中,另一個專用的程式去定時發郵件。郵件傳送失敗了會重發的,可靠性非常高的。

不過大廠貌似都使用專用的訊息佇列,能力有限沒時間精力去搗騰那些高大上的東西,就拿redis來做做實驗

安裝redisf服務

nugetStackExchange.Redis

    class Program
    {
        static void Main(string[] args)
        {
            using (var redis= ConnectionMultiplexer.Connect("localhost:6379
")) { var db = redis.GetDatabase(); db.ListRightPush("Sys_Order_Sms", $"尊敬的客戶,你已經完成下單,訂單號為{new Random().Next(100000, 999999)}"); } } }
    class Program
    {
        static void Main(string[] args)
        {
            using (var redis = ConnectionMultiplexer.Connect("
localhost:6379")) { var db = redis.GetDatabase(); while (true) { string sms = db.ListRightPop("Sys_Order_Sms"); if (sms != null) { Console.WriteLine($"傳送簡訊:{sms}
"); } else { Console.WriteLine("沒有簡訊需要傳送"); } Thread.Sleep(5000); } } } }