Ejemplo n.º 1
0
        public void Subscribe(string busType = "wxcardspc", string eventType = "user_view_card", long mallID = 10001)
        {
            var routeKey = string.Format(_KeyFormat, eventType, mallID);
            var queue    = routeKey + "." + busType;
            var b        = _RabbitClient.Subscribe <string>(queue, _ExChange, routeKey, msg => MessageReceived(msg));

            Console.WriteLine("Subscribe q:{0} ex:{1} k:{2} result:{3}", queue, _ExChange, routeKey, b);
        }
Ejemplo n.º 2
0
        public void Test_SubscribeAndPublish()
        {
            _rabbitClient.Publish(
                new TestMessage()
            {
                Name = $"当前时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"
            },
                config =>
            {
                config.PlanPublishTime = DateTime.Now.AddSeconds(1);
            });

            _rabbitClient.Subscribe <TestMessage>(
                async(message, context) =>
            {
                Console.WriteLine(message.Name);
                await Task.FromResult(0);
            });

            Thread.Sleep(3000);
        }
Ejemplo n.º 3
0
 public void SubscribeOnRaceStart(Action <StartMessage> startMessageAction)
 {
     client.Subscribe(startMessageAction);
 }