예제 #1
0
 static void Main(string[] args)
 {
     Parallel.For(0, RabbitMQConfig.ThreadCount, i =>
     {
         IMessageCustomer customer = new MessageCustomer("test");
         customer.StartListening();
         customer.ReceiveMessageCallback = message =>
         {
             Console.WriteLine("接收到消息:" + message);
             return(true);
         };
     });
     Console.Read();
 }
예제 #2
0
        public IMessageCustomer CreateCustomer(string queueName)
        {
            IMessageCustomer customer;

            if (!Customers.ContainsKey(queueName))
            {
                customer = new MessageCustomer(queueName);
                Customers.Add(queueName, customer);
            }
            else
            {
                customer = Customers[queueName];
            }
            return(customer);
        }
예제 #3
0
        static void Main(string[] args)
        {
            while (true)
            {
                IMessageCustomer customer = new MessageCustomer("test");
                customer.StartListening();
                customer.ReceiveMessageCallback = message =>
                {
                    Console.WriteLine("接收到消息:" + message);
                    return(false);
                };

                Thread.Sleep(2000);
            }
            Console.Read();
        }