| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections.Generic;
- using Library;
- using System.Linq;
- using System.Threading;
- using RabbitMQ.Client;
- using System.Text;
- namespace MySystem
- {
- public class MpOrderService
- {
- public readonly static MpOrderService Instance = new MpOrderService();
- private MpOrderService()
- { }
- public void Start()
- {
- Thread th = new Thread(SendMsg);
- th.IsBackground = true;
- th.Start();
- }
- public void SendMsg()
- {
- RabbitMQClient.Instance.SendMsg("QUEUE_LKB_TRADE_DIVISION");
- }
- public void dosomething(IModel channel, string QueueName)
- {
- while (true)
- {
- string content = MpRedisDbconn.Instance.RPop<string>("MpOrderQueue");
- if (!string.IsNullOrEmpty(content))
- {
- try
- {
- channel.BasicPublish("", QueueName, null, Encoding.Default.GetBytes(content));
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "设置激活奖励异常");
- }
- }
- else
- {
- Thread.Sleep(500);
- }
- }
- }
- }
- }
|