コード例 #1
0
        public CommandProcessor(EnvironmentContext context,string routekey)
        {
            MessageConsumer = new MessageConsumer();
            MessageProducer = new MessageProducer();

            if (String.IsNullOrEmpty(routekey))
                throw new Exception("Route key must not be null");

            if (context == null)
                throw new Exception("CommandProcessor environment context must not be null");

            _environment = context;
            RouteKey = routekey;
            MessageConsumer.OnMessageReceived += (msg) =>
            {
                if (msg is CommandMessage)
                {
                    try
                    {
                        if (msg.RoutingKey.Equals(_environment.GetRoute(RouteKey),StringComparison.CurrentCultureIgnoreCase))
                        {
                              HandleMessage(msg);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log(msg.Ticket,ex.Message);
                    }
                }
            };
        }
コード例 #2
0
 public void EnvironmentBuildsRouteKey()
 {
     var env = new EnvironmentContext();
     Assert.AreEqual("dev.admin.somequeue",env.GetRoute("somequeue"));
 }