KxsActService.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 KxsActService
  11. {
  12. public readonly static KxsActService Instance = new KxsActService();
  13. private KxsActService()
  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>("KxsActQueue");
  26. if (!string.IsNullOrEmpty(content))
  27. {
  28. try
  29. {
  30. // RabbitMQClient.Instance.SendMsg3(content, "QUEUE_KXS_ACT_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. public void StartMp()
  44. {
  45. Thread th = new Thread(dosomethingMp);
  46. th.IsBackground = true;
  47. th.Start();
  48. }
  49. public void dosomethingMp()
  50. {
  51. while (true)
  52. {
  53. string content = MpRedisDbconn.Instance.RPop<string>("KxsActQueue");
  54. if (!string.IsNullOrEmpty(content))
  55. {
  56. try
  57. {
  58. // RabbitMQClient.Instance.SendMsg3(content, "QUEUE_KXS_ACT_DIVISION");
  59. }
  60. catch (Exception ex)
  61. {
  62. Utils.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "推送客小爽码牌激活数据异常");
  63. }
  64. }
  65. else
  66. {
  67. Thread.Sleep(500);
  68. }
  69. }
  70. }
  71. }
  72. }