Ejemplo n.º 1
0
        public void CreateOrder()
        {
            ConfirmOrder confirmOrder = this.confirmOrder;

            this.bus = BusBuilder.CreateMessageBus();
            var sub    = new ConfirmOrderRPCSubscriber(bus, dataContext);
            var result = sub.Response(confirmOrder, new MessageContext()
            {
                GlobalRequestId = Guid.NewGuid()
            }).Result;

            Assert.IsNotNull(result);
        }
Ejemplo n.º 2
0
        //接收訊息
        public static void Subscribe()
        {
            IBus bus = BusBuilder.CreateMessageBus();

            try
            {
                TaskHandler taskHandler = new TaskHandler();
                //bus.Subscribe<ConvertTask>("task", c => taskHandler.Convert(c));
            }
            catch (EasyNetQException ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        //發送訊息
        public static void Publish(ConvertTask task)
        {
            IBus bus = BusBuilder.CreateMessageBus();

            try
            {
                bus.Publish(task);
            }
            catch (EasyNetQException ex)
            {
                throw ex;
            }
            bus.Dispose();
        }
Ejemplo n.º 4
0
        public void Init()
        {
            var path1 = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;

            AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(path1, "App_Data"));
            if (bus == null)
            {
                var connectionString = ConfigurationManager.AppSettings["rabbitMQ"];
                if (connectionString == null)
                {
                    throw new Exception("easynetq connection string is missing or empty");
                }

                bus = BusBuilder.CreateMessageBus();
            }
        }