Exemplo n.º 1
0
        public async Task Initialize()
        {
            HorseMqOptions horseMqOptions = new HorseMqOptions();

            horseMqOptions.AutoQueueCreation  = true;
            horseMqOptions.AcknowledgeTimeout = TimeSpan.FromSeconds(90);
            horseMqOptions.MessageTimeout     = TimeSpan.FromSeconds(12);
            horseMqOptions.Status             = QueueStatus.Broadcast;

            Server = HorseMqBuilder.Create()
                     .AddOptions(horseMqOptions)
                     .AddQueueEventHandler(new TestQueueHandler(this))
                     .UseDeliveryHandler(d => Task.FromResult <IMessageDeliveryHandler>(new TestDeliveryHandler(this)))
                     .AddClientHandler(new TestClientHandler(this))
                     .AddAdminAuthorization <TestAdminAuthorization>()
                     .Build();

            await Server.CreateQueue("broadcast-a", o => o.Status = QueueStatus.Broadcast);

            await Server.CreateQueue("push-a", o => o.Status = QueueStatus.Push);

            await Server.CreateQueue("push-a-cc", o => o.Status = QueueStatus.Push);

            await Server.CreateQueue("rr-a", o => o.Status = QueueStatus.RoundRobin);

            await Server.CreateQueue("pull-a", o => o.Status = QueueStatus.Pull);

            await Server.CreateQueue("cache-a", o => o.Status = QueueStatus.Cache);
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            HorseMq mq = HorseMqBuilder.Create()
                         .AddClientHandler <ClientHandler>()
                         .AddQueueEventHandler <QueueEventHandler>()
                         .UseJustAllowDeliveryHandler()
                         .Build();

            var sampleMessageRouter        = mq.AddRouter("SAMPLE-MESSAGE-ROUTER", RouteMethod.Distribute);
            var sampleMessageQueueBinding  = new QueueBinding("sample-message-queue-binding", "SAMPLE-MESSAGE-QUEUE", 1, BindingInteraction.Response);
            var sampleMessageDirectBinding = new DirectBinding("sample-message-direct-binding", "@type:SAMPLE-MESSAGE-CONSUMER", 2, BindingInteraction.Response, RouteMethod.RoundRobin);

            sampleMessageRouter.AddBinding(sampleMessageQueueBinding);
            sampleMessageRouter.AddBinding(sampleMessageDirectBinding);

            var giveMeGuidRequestRouter  = mq.AddRouter("GIVE-ME-REQUEST-ROUTER", RouteMethod.Distribute);
            var giveMeGuidRequestHandler = new DirectBinding("sample-message-direct-binding", "@name:GIVE-ME-GUID-REQUEST-HANDLER-CONSUMER", 2, BindingInteraction.Response);

            giveMeGuidRequestRouter.AddBinding(giveMeGuidRequestHandler);

            HorseServer server = new HorseServer();

            server.UseHorseMq(mq);
            server.Run(15500);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            HorseMq mq = HorseMqBuilder.Create()
                         .AddOptions(o => o.Status = QueueStatus.Push)
                         .AddClientHandler <ClientHandler>()
                         .AddQueueEventHandler <QueueEventHandler>()
                         .AddPersistentQueues()
                         .UsePersistentDeliveryHandler(DeleteWhen.AfterAcknowledgeReceived, ProducerAckDecision.AfterSaved)
                         .Build();

            mq.LoadPersistentQueues();

            HorseServer server = new HorseServer();

            server.UseHorseMq(mq);
            server.Run(26222);
        }