コード例 #1
0
ファイル: ScenarioTests.cs プロジェクト: petedishman/HareDu
 public void I_Want_To_Create_A_New_Queue_And_Bind_It_To_An_Existing_Exchange()
 {
     try
     {
         var client = HareDuFactory.New(x =>
         {
             x.ConnectTo("http://localhost:15672");
             x.EnableLogging(y => y.Logger("HareDuLogger"));
         });
         string virtualHost            = "MyVirtualHostScenarioTest1";
         string exchange               = "MyExchangeScenarioTest1";
         string username               = "******";
         string password               = "******";
         string queue                  = "MyQueueScenarioTest1";
         var    virtualHostResources   = client.Factory <VirtualHostResources>(x => x.Credentials(username, password));
         var    createNewQueueResponse = virtualHostResources.Queue
                                         .New(x => x.Queue(queue),
                                              x => x.IsDurable(),
                                              x => x.VirtualHost(virtualHost))
                                         .Response();
         string routingKey            = "test_routing_key";
         var    createBindingResponse = virtualHostResources.QueueExchangeBindings
                                        .New(x => x.Binding(queue, exchange),
                                             x => x.UsingRoutingKey(routingKey),
                                             x => x.VirtualHost(virtualHost))
                                        .Response();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
コード例 #2
0
ファイル: ScenarioTests.cs プロジェクト: petedishman/HareDu
 public void I_Want_To_Create_A_New_Exchange_On_An_Existing_VirtualHost()
 {
     try
     {
         var client = HareDuFactory.New(x =>
         {
             x.ConnectTo("http://localhost:15672");
             x.EnableLogging(y => y.Logger("HareDuLogger"));
         });
         string virtualHost               = "MyVirtualHostScenarioTest1";
         string exchange                  = "MyExchangeScenarioTest2";
         string username                  = "******";
         string password                  = "******";
         var    virtualHostResources      = client.Factory <VirtualHostResources>(x => x.Credentials(username, password));
         var    createNewExchangeResponse = virtualHostResources.Exchange
                                            .New(x => x.Exchange(exchange),
                                                 x =>
         {
             x.IsDurable();
             x.UsingRoutingType(y => y.Fanout());
         },
                                                 x => x.VirtualHost(virtualHost))
                                            .Response();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.InnerException.Message);
     }
 }
コード例 #3
0
ファイル: HareDuTestBase.cs プロジェクト: petedishman/HareDu
 public virtual void Setup()
 {
     Client = HareDuFactory.New(x =>
     {
         x.ConnectTo(Settings.Default.HostUrl);
         x.EnableLogging(y => y.Logger(Settings.Default.LoggerName));
     });
 }
コード例 #4
0
        private IEnumerable <RabbitQueue> GetErrorQueues(Models.HareDuSettings settings)
        {
            HareDuClient         client = HareDuFactory.New(x => x.ConnectTo(settings.RabbitUrl));
            VirtualHostResources res    = client.Factory <VirtualHostResources>(x => x.Credentials(settings.Username, settings.Password));
            IEnumerable <Queue>  queues = res.Queue.GetAll(target => target.VirtualHost(settings.Vhost)).Data().ToList();

            IEnumerable <RabbitQueue> results = queues.Where(q => q.Name.EndsWith("_error")).Select(x =>
                                                                                                    new RabbitQueue(x.Name, x.Messages, x.MessagesReady)
            {
            }).ToList();

            return(results);
        }
コード例 #5
0
        public QueueMonitorService()
        {
            _scheduler = HareDuScheduler.CreateScheduler();
            _config    = new HareShowConfig();

            var clientConfig = _config.GetConfigSection("HareDuSettings/Client");
            var url          = clientConfig.Get("url");
            var loggerName   = clientConfig.Get("logger");

            _client = HareDuFactory.New(x =>
            {
                x.ConnectTo(url);
                x.EnableLogging(y => y.Logger(loggerName));
            });
        }
コード例 #6
0
ファイル: ScenarioTests.cs プロジェクト: petedishman/HareDu
        public void I_Want_To_See_Queue_And_Message_Stats()
        {
            try
            {
                var client = HareDuFactory.New(x =>
                {
                    x.ConnectTo("http://localhost:15672");
                    x.EnableLogging(y => y.Logger("HareDuLogger"));
                });
                var overview = client
                               .Factory <OverviewResources>(x => x.Credentials("guest", "guest"))
                               .Get()
                               .Data();

                Console.WriteLine("******************** Queue Totals ********************");
                Console.WriteLine("Messages: {0}", overview.QueueTotals.Messages);
                Console.WriteLine("Messages Ready: {0}", overview.QueueTotals.MessagesReady);
                Console.WriteLine("Messages Unacknowledged: {0}", overview.QueueTotals.MessagesUnacknowledged);

                Console.WriteLine("******************** Message Details ********************");
                Console.WriteLine("Rate: {0}", overview.QueueTotals.MessagesDetails.Rate);
                Console.WriteLine("Interval: {0}", overview.QueueTotals.MessagesDetails.Interval);
                Console.WriteLine("Last Event: {0}", overview.QueueTotals.MessagesDetails.LastEvent);

                Console.WriteLine("******************** Ready Messages ********************");
                Console.WriteLine("Rate: {0}", overview.QueueTotals.MessagesReadyDetails.Rate);
                Console.WriteLine("Interval: {0}", overview.QueueTotals.MessagesReadyDetails.Interval);
                Console.WriteLine("Last Event: {0}", overview.QueueTotals.MessagesReadyDetails.LastEvent);

                Console.WriteLine("******************** Unacknowledged Messages ********************");
                Console.WriteLine("Rate: {0}", overview.QueueTotals.MessagesUnacknowledgedDetails.Rate);
                Console.WriteLine("Interval: {0}", overview.QueueTotals.MessagesUnacknowledgedDetails.Interval);
                Console.WriteLine("Last Event: {0}", overview.QueueTotals.MessagesUnacknowledgedDetails.LastEvent);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #7
0
ファイル: ScenarioTests.cs プロジェクト: petedishman/HareDu
 public void I_Want_To_Create_A_New_VirtualHost_With_A_User()
 {
     try
     {
         var client = HareDuFactory.New(x =>
         {
             x.ConnectTo("http://localhost:15672");
             x.EnableLogging(y => y.Logger("HareDuLogger"));
         });
         var    virtualHostResources      = client.Factory <VirtualHostResources>(x => x.Credentials("guest", "guest"));
         string virtualHost               = "MyVirtualHostScenarioTest1";
         var    createVirtualHostResponse = virtualHostResources.New(x => x.VirtualHost(virtualHost))
                                            .Response();
         var    userResources      = client.Factory <UserResources>(x => x.Credentials("guest", "guest"));
         string username           = "******";
         string password           = "******";
         var    createUserResponse = userResources.New(x => x.User(username),
                                                       x =>
         {
             x.WithPassword(password);
             x.WithTags(y => y.Administrator());
         })
                                     .Response();
         var setUserPermissionsResponse = userResources.Permissions
                                          .Set(x => x.User(username),
                                               x =>
         {
             x.Configure(".*");
             x.Read(".*");
             x.Write(".*");
         },
                                               x => x.VirtualHost(virtualHost))
                                          .Response();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }