Exemplo n.º 1
0
        public void Should_be_able_to_get_a_message()
        {
            var queue = advancedBus.QueueDeclare("get_test");

            advancedBus.Publish(Exchange.GetDefault(), "get_test", false, new Message <MyMessage>(new MyMessage {
                Text = "Oh! Hello!"
            }));

            var getResult = advancedBus.Get <MyMessage>(queue);

            if (getResult.MessageAvailable)
            {
                Console.Out.WriteLine("Got message: {0}", getResult.Message.Body.Text);
            }
            else
            {
                Console.Out.WriteLine("Failed to get message!");
            }
        }
Exemplo n.º 2
0
        public ActionResult GetMessages(string type)
        {
            if (type == null)
            {
                return(new JsonResult()
                {
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                    Data = new { Number = "-1" }
                });
            }

            var queue = _advancedBus.QueueDeclare(string.Format("FirstScreen.Queue.{0}", type));

            _advancedBus.Bind(_exchange, queue, type);

            var result = _advancedBus.Get <string>(queue);

            return(new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new { Number = result != null ? result.Message.Body : "-1" }
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// 메세지 가져오기
        /// </summary>
        /// <param name="queueName">메세지 큐 이름</param>
        /// <returns>IBasicGetResult</returns>
        public IBasicGetResult Get(string queueName)
        {
            var queue = new Queue(queueName, false);

            return(advancedBus.Get(queue));
        }