PrizeSendService.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using Library;
  4. using System.Linq;
  5. using System.Threading;
  6. using System.Text;
  7. namespace MySystem
  8. {
  9. public class PrizeSendService
  10. {
  11. public readonly static PrizeSendService Instance = new PrizeSendService();
  12. private PrizeSendService()
  13. { }
  14. public void Start()
  15. {
  16. Thread th = new Thread(dosomething);
  17. th.IsBackground = true;
  18. th.Start();
  19. }
  20. public void dosomething()
  21. {
  22. while (true)
  23. {
  24. string content = RedisDbconn.Instance.RPop<string>("PrizeSendQueue");
  25. if (!string.IsNullOrEmpty(content))
  26. {
  27. try
  28. {
  29. RabbitMQPrize.Instance.SendMsg(content, "PRIZE_SEND_QUEUE");
  30. }
  31. catch (Exception ex)
  32. {
  33. function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "推送客小爽机具数据异常");
  34. }
  35. }
  36. else
  37. {
  38. Thread.Sleep(2000);
  39. }
  40. }
  41. }
  42. public void StartMp()
  43. {
  44. Thread th = new Thread(dosomethingMp);
  45. th.IsBackground = true;
  46. th.Start();
  47. }
  48. public void dosomethingMp()
  49. {
  50. while (true)
  51. {
  52. string content = MpRedisDbconn.Instance.RPop<string>("KxsActQueue");
  53. if (!string.IsNullOrEmpty(content))
  54. {
  55. try
  56. {
  57. RabbitMQClient.Instance.SendMsg3(content, "QUEUE_KXS_ACT_DIVISION");
  58. }
  59. catch (Exception ex)
  60. {
  61. function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "推送客小爽码牌激活数据异常");
  62. }
  63. }
  64. else
  65. {
  66. Thread.Sleep(500);
  67. }
  68. }
  69. }
  70. }
  71. }