KxsOrderService.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using Library;
  4. using System.Linq;
  5. using System.Threading;
  6. using RabbitMQ.Client;
  7. using System.Text;
  8. namespace MySystem
  9. {
  10. public class KxsOrderService
  11. {
  12. public readonly static KxsOrderService Instance = new KxsOrderService();
  13. private KxsOrderService()
  14. { }
  15. public void Start()
  16. {
  17. Thread th = new Thread(dosomething);
  18. th.IsBackground = true;
  19. th.Start();
  20. }
  21. public void dosomething()
  22. {
  23. while (true)
  24. {
  25. string content = RedisDbconn.Instance.RPop<string>("KxsOrderQueue");
  26. if (!string.IsNullOrEmpty(content))
  27. {
  28. try
  29. {
  30. RabbitMQClient.Instance.SendMsg2(content, "QUEUE_KXS_ORDER_DIVISION");
  31. }
  32. catch (Exception ex)
  33. {
  34. Utils.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "客小爽订单推送异常");
  35. }
  36. }
  37. else
  38. {
  39. Thread.Sleep(500);
  40. }
  41. }
  42. }
  43. }
  44. }