• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BuiltinHandlerActivator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BuiltinHandlerActivator的典型用法代码示例。如果您正苦于以下问题:C# BuiltinHandlerActivator类的具体用法?C# BuiltinHandlerActivator怎么用?C# BuiltinHandlerActivator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BuiltinHandlerActivator类属于命名空间,在下文中一共展示了BuiltinHandlerActivator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LooksGood

        public void LooksGood()
        {
            using (var activator = new BuiltinHandlerActivator())
            {
                Console.WriteLine(ConnectionString);

                var bus = Configure.With(activator)
                    .Transport(t => t.UseAzureServiceBus(ConnectionString, "contenttypetest"))
                    .Options(o => o.SetNumberOfWorkers(0))
                    .Start();

                bus.Advanced.Workers.SetNumberOfWorkers(0);

                var message = new RigtigBesked
                {
                    Text = "hej med dig min ven! DER ER JSON HERI!!!",
                    Embedded = new RigtigEmbedded
                    {
                        Whatever = new[] {1, 2, 3},
                        Message = "I'm in here!!"
                    }
                };

                bus.SendLocal(message).Wait();
            }
        }
开发者ID:RichieYang,项目名称:Rebus,代码行数:26,代码来源:AzureServiceBusContentTypeTest.cs


示例2: Main

        static void Main()
        {
            using (var creditAssessmentClient = new HttpClient())
            {
                creditAssessmentClient.BaseAddress = new Uri(Config.CreditAssessmentUrl);

                using (var activator = new BuiltinHandlerActivator())
                {
                    activator.Register((bus, context) => new ConfirmationHandler(bus, creditAssessmentClient));

                    Configure.With(activator)
                        .ConfigureEndpoint(Config.Queues.Confirmation)
                        .Options(o =>
                        {
                            o.SetMaxParallelism(100);
                        })
                        .Start();

                    activator.Bus.Subscribe<TradeCreated>().Wait();

                    Console.WriteLine("===== Confirmation =====");

                    Console.WriteLine("Press ENTER to quit");
                    Console.ReadLine();
                }
            }
        }
开发者ID:rebus-org,项目名称:RebusDemos,代码行数:27,代码来源:Program.cs


示例3: CanForwardToMultipleRecipients

        public async Task CanForwardToMultipleRecipients()
        {
            var network = new InMemNetwork();
            var activator = new BuiltinHandlerActivator();

            Using(activator);

            var recipients = new[] { "recipient-A", "recipient-B" }.ToList();

            recipients.ForEach(network.CreateQueue);

            Configure.With(activator)
                .Transport(t => t.UseInMemoryTransport(network, "forwarder"))
                .Routing(t =>
                {
                    t.AddTransportMessageForwarder(async transportMessage => ForwardAction.ForwardTo(recipients));
                })
                .Start();

            await activator.Bus.SendLocal("HEJ MED DIG!!!");

            var transportMessages = await Task.WhenAll(recipients.Select(async queue =>
            {
                var message = await network.WaitForNextMessageFrom(queue);

                return message;
            }));

            Assert.That(transportMessages.Length, Is.EqualTo(2));
        }
开发者ID:rebus-org,项目名称:Rebus,代码行数:30,代码来源:TestTransportMessageForwarding.cs


示例4: Main

        static void Main()
        {
            using (var adapter = new BuiltinHandlerActivator())
            {
                adapter.Handle<Job>(async job =>
                {
                    Console.WriteLine("Processing job {0}", job.JobNumber);

                    await Task.Delay(TimeSpan.FromMilliseconds(300));
                });

                Configure.With(adapter)
                    .Logging(l => l.ColoredConsole(LogLevel.Warn))
                    .Transport(t => t.UsePostgreSql("server=localhost;port=5433;database=rebus2_test; user id=test; password=test; maximum pool size=30", "messages", "consumer"))
                    .Options(o =>
                    {
                        o.SetNumberOfWorkers(10);
                        o.SetMaxParallelism(20);
                    })
                    .Start();

                Console.WriteLine("Consumer listening - press ENTER to quit");
                Console.ReadLine();
            }
        }
开发者ID:rebus-org,项目名称:RebusSamples,代码行数:25,代码来源:Program.cs


示例5: NumberOfWorkersIsLimitedByMaxParallelism

        public void NumberOfWorkersIsLimitedByMaxParallelism()
        {
            var counter = new WorkerCounter();

            using (var adapter = new BuiltinHandlerActivator())
            {
                Configure.With(adapter)
                    .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "worker-/parallelism-test"))
                    .Options(o =>
                    {
                        o.SetMaxParallelism(1);
                        o.SetNumberOfWorkers(10);

                        o.Decorate<IWorkerFactory>(c =>
                        {
                            counter.SetWorkerFactory(c.Get<IWorkerFactory>());

                            return counter;
                        });
                    })
                    .Start();

                Thread.Sleep(TimeSpan.FromSeconds(1));
            }

            Assert.That(counter.NumberOfWorkersCreated, Is.EqualTo(1));
        }
开发者ID:xenoputtss,项目名称:Rebus,代码行数:27,代码来源:TestWorkerAndParallelismConfiguration.cs


示例6: SetUp

        protected override void SetUp()
        {
            _activator = Using(new BuiltinHandlerActivator());

            _snitch = new BackoffSnitch();

            Configure.With(_activator)
                .Logging(l => l.Console(LogLevel.Info))
                .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "busy-test"))
                .Options(o =>
                {
                    o.SetNumberOfWorkers(1);
                    o.SetMaxParallelism(500);

                    o.SetBackoffTimes(TimeSpan.FromSeconds(0.2));

                    // install the snitch
                    o.Decorate<ISyncBackoffStrategy>(c =>
                    {
                        var syncBackoffStrategy = c.Get<ISyncBackoffStrategy>();
                        _snitch.SyncBackoffStrategy = syncBackoffStrategy;
                        return _snitch;
                    });

                    o.Decorate<ITransport>(c =>
                    {
                        var transport = c.Get<ITransport>();

                        return new IntroducerOfLatency(transport, receiveLatencyMs: 10);
                    });
                })
                .Start();
        }
开发者ID:xenoputtss,项目名称:Rebus,代码行数:33,代码来源:TestBackoffBehaviorWhenBusy.cs


示例7: StartBus

        static IBus StartBus(InMemNetwork network, string queueName, ConcurrentQueue<string> recordedEvents)
        {
            var activator = new BuiltinHandlerActivator();

            activator.Handle(async (string message) =>
            {
                recordedEvents.Enqueue($"GOT MESSAGE: {message}");
            });

            return Configure.With(activator)
                .Transport(t => t.UseInMemoryTransport(network, queueName))
                .Options(o =>
                {
                    o.Decorate(c =>
                    {
                        var events = c.Get<BusLifetimeEvents>();

                        events.BusStarting += () => recordedEvents.Enqueue("Bus starting");
                        events.BusStarted += () => recordedEvents.Enqueue("Bus started");
                        events.BusDisposing += () => recordedEvents.Enqueue("Bus disposing");
                        events.BusDisposed += () => recordedEvents.Enqueue("Bus disposed");

                        return events;
                    });
                })
                .Start();
        }
开发者ID:xenoputtss,项目名称:Rebus,代码行数:27,代码来源:TestBusLifetimeEvents.cs


示例8: Main

        static void Main()
        {
            // serve the web app out of the "site" directory directly in the source code - allows for
            // quicker edit/reload iterations
            var webAppBaseDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "site");

            using (var activator = new BuiltinHandlerActivator())
            {
                Configure.With(activator)
                    .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "owin-test"))
                    .Options(o =>
                    {
                        // add the web host
                        o.AddWebHost(ListenUrl, app =>
                        {
                            // serve web application out of the configured base directory
                            app.UseFileServer(new FileServerOptions
                            {
                                FileSystem = new PhysicalFileSystem(webAppBaseDir),
                                DefaultFilesOptions = { DefaultFileNames = { "index.html" } }
                            });

                            // host a simple API
                            app.Map("/api/hello", a => a.Run(GetTimedGreeting));
                        });
                    })
                    .Start();

                // invoke default browser and navigate to the URL
                Process.Start(ListenUrl);

                Console.WriteLine("Press ENTER to quit");
                Console.ReadLine();
            }
        }
开发者ID:rebus-org,项目名称:RebusSamples,代码行数:35,代码来源:Program.cs


示例9: Main

        static void Main()
        {
            using (var adapter = new BuiltinHandlerActivator())
            {
                adapter.Handle<Reply>(async reply =>
                {
                    Console.WriteLine("Got reply '{0}' (from OS process {1})", reply.KeyChar, reply.OsProcessId);
                });

                Configure.With(adapter)
                    .Logging(l => l.ColoredConsole(minLevel: LogLevel.Warn))
                    .Transport(t => t.UseSqlServer("server=.; database=rebus; trusted_connection=true", "Messages", "producer.input"))
                    .Routing(r => r.TypeBased().MapAssemblyOf<Job>("consumer.input"))
                    .Start();

                Console.WriteLine("Press Q to quit or any other key to produce a job");
                while (true)
                {
                    var keyChar = char.ToLower(Console.ReadKey(true).KeyChar);

                    switch (keyChar)
                    {
                        case 'q':
                            goto quit;

                        default:
                            adapter.Bus.Send(new Job(keyChar)).Wait();
                            break;
                    }
                }

            quit:
                Console.WriteLine("Quitting...");
            }
        }
开发者ID:nls75,项目名称:RebusSamples,代码行数:35,代码来源:Program.cs


示例10: NizzleName

        public async Task NizzleName()
        {
            var gotMessage = new ManualResetEvent(false);

            using (var activator = new BuiltinHandlerActivator())
            {
                activator.Handle<string>(async s =>
                {
                    Console.WriteLine("Got message: {0}", s);
                    gotMessage.Set();
                });

                Configure.With(activator)
                    .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "bimse"))
                    .Options(o =>
                    {
                        o.Register<IWorkerFactory>(c =>
                        {
                            var transport = c.Get<ITransport>();
                            var pipeline = c.Get<IPipeline>();
                            var pipelineInvoker = c.Get<IPipelineInvoker>();
                            var rebusLoggerFactory = c.Get<IRebusLoggerFactory>();
                            return new AsyncTaskWorkerFactory(transport, pipeline, pipelineInvoker, rebusLoggerFactory);
                        });
                    })
                    .Start();

                await activator.Bus.SendLocal("hej med dig min ven");

                gotMessage.WaitOrDie(TimeSpan.FromSeconds(3));
            }
        }
开发者ID:hdrachmann,项目名称:Rebus,代码行数:32,代码来源:TestAlternativeWorkerFactory.cs


示例11: SetUp

        protected override void SetUp()
        {
            var network = new InMemNetwork();

            _events = new ConcurrentQueue<string>();
            _uowActivator = new BuiltinHandlerActivator();
            _otherActivator = new BuiltinHandlerActivator();

            Using(_uowActivator);
            Using(_otherActivator);

            _uowBus = Configure.With(_uowActivator)
                .Logging(l => l.Console(LogLevel.Warn))
                .Transport(t => t.UseInMemoryTransport(network, UowQueueName))
                .Options(o =>
                {
                    o.EnableUnitOfWork(c => _events,
                        commitAction: (c, e) => RegisterEvent("uow committed"),
                        rollbackAction: (c, e) => RegisterEvent("uow rolled back"),
                        cleanupAction: (c, e) => RegisterEvent("uow cleaned up"));

                    o.SimpleRetryStrategy(maxDeliveryAttempts: 1);

                    //o.LogPipeline(true);
                })
                .Start();

            Configure.With(_otherActivator)
                .Logging(l => l.Console(LogLevel.Warn))
                .Transport(t => t.UseInMemoryTransport(network, OtherQueueName))
                .Start();
        }
开发者ID:RichieYang,项目名称:Rebus,代码行数:32,代码来源:TestUnitOfWork.cs


示例12: SetUp

        protected override void SetUp()
        {
            _activator = Using(new BuiltinHandlerActivator());

            _waitedSeconds = new ConcurrentQueue<double>();

            _rebusConfigurer = Configure.With(_activator)
                .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "test backoff"))
                .Options(o =>
                {
                    o.SetBackoffTimes(TimeSpan.FromSeconds(0.2), TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(1));

                    o.Decorate<ITransport>(c =>
                    {
                        var transport = c.Get<ITransport>();
                        var transportTap = new TransportTap(transport);

                        transportTap.NoMessageReceived += () =>
                        {
                            var elapsedSinceStart = DateTime.UtcNow - _busStartTime;
                            var elapsedSeconds = Math.Round(elapsedSinceStart.TotalSeconds, 1);
                            _waitedSeconds.Enqueue(elapsedSeconds);
                        };

                        return transportTap;
                    });

                    o.SetMaxParallelism(10);
                    o.SetNumberOfWorkers(1);
                });
        }
开发者ID:xenoputtss,项目名称:Rebus,代码行数:31,代码来源:TestCustomizedBackoffTime.cs


示例13: SetUp

        protected override void SetUp()
        {
            using (var transport = new RabbitMqTransport(ConnectionString, _receiverQueueName, new NullLoggerFactory()))
            {
                transport.PurgeInputQueue();
            }

            _receiver = new BuiltinHandlerActivator();

            Using(_receiver);

            Configure.With(_receiver)
                .Logging(l => l.Console(LogLevel.Info))
                .Transport(t => t.UseRabbitMq(ConnectionString, _receiverQueueName).Prefetch(1))
                .Options(o =>
                {
                    o.SetNumberOfWorkers(1);
                    o.SetMaxParallelism(1);
                })
                .Start();

            _sender = Configure.With(new BuiltinHandlerActivator())
                .Logging(l => l.Console(LogLevel.Info))
                .Transport(t => t.UseRabbitMqAsOneWayClient(ConnectionString))
                .Routing(r => r.TypeBased().MapFallback(_receiverQueueName))
                .Start();

            Using(_sender);
        }
开发者ID:RichieYang,项目名称:Rebus,代码行数:29,代码来源:TestRabbitMqReconnection.cs


示例14: Main

        static void Main(string[] args)
        {
            using (var activator = new BuiltinHandlerActivator())
            {
                var bus = Configure.With(activator)
                            .Transport(t => t.UseFileSystem(messageQueueFilePath, "rebusStarbucks.cashier"))
                            //.Transport(t => t.UseMsmq("rebusStarbucks.cashier"))
                            //.Transport(t => { t.Register(context => new Msmq.MsmqTransport("rebusStarbucks.cashier", true)); })
                            .Routing(r =>
                            {
                                r.TypeBased()
                                .Map<PaymentDueMessage>("rebusStarbucks.client")
                                .Map<NewOrderMessage>("rebusStarbucks.client")
                                .Map<PaymentCompleteMessage>("rebusStarbucks.barista");
                            })
                            .Options(op => {
                                op.SetMaxParallelism(1).EnableEncryption("VW6DcqJioLHnV1b9oPnDFCYAGB7VxJcY");
                            })
                            .Sagas(x => x.StoreInJsonFile(AppDomain.CurrentDomain.BaseDirectory))
                            .Start();

                activator.Bus.Subscribe<NewOrderMessage>();

                activator.Register(() => new CashierSaga(bus));
                Console.ReadLine();
            }
        }
开发者ID:BredStik,项目名称:RebusStarbucks,代码行数:27,代码来源:Program.cs


示例15: DoesNotDispatchMessageWithNullBus

        public void DoesNotDispatchMessageWithNullBus()
        {
            var busInstances = new ConcurrentQueue<IBus>();

            using (var activator = new BuiltinHandlerActivator())
            {
                activator.Handle<string>(async (bus, message) =>
                {
                    busInstances.Enqueue(bus);
                });

                Configure.With(activator)
                    .Logging(l => l.ColoredConsole(LogLevel.Warn))
                    .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "race-condition"))
                    .Options(o =>
                    {
                        o.SetNumberOfWorkers(1);
                        o.SetMaxParallelism(1);
                    })
                    .Start();

                Task.WaitAll(Enumerable.Range(0, 1000)
                    .Select(i => activator.Bus.SendLocal($"message-{i}"))
                    .ToArray());
            }

            Thread.Sleep(1000);

            var numberOfNulls = busInstances.Count(i => i == null);

            Assert.That(numberOfNulls, Is.EqualTo(0),
                "Did not expect any messages to be dispatched with a NULL bus instance");
        }
开发者ID:rebus-org,项目名称:Rebus,代码行数:33,代码来源:BuiltinHandlerActivatorDisposalRaceCondition.cs


示例16: StartBus

        Tuple<BuiltinHandlerActivator, CountingTransport> StartBus(bool customizeBackoffTimes)
        {
            var activator = new BuiltinHandlerActivator();
            CountingTransport countingTransport = null;

            Configure.With(activator)
                .Logging(l => l.Console(minLevel: LogLevel.Warn))
                .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "customized-backoff"))
                .Options(o =>
                {
                    o.Decorate<ITransport>(c =>
                    {
                        var transport = c.Get<ITransport>();
                        countingTransport = new CountingTransport(transport);
                        return countingTransport;
                    });

                    o.SetNumberOfWorkers(20);
                    o.SetMaxParallelism(20);

                    if (customizeBackoffTimes)
                    {
                        o.SetBackoffTimes(
                            TimeSpan.FromMilliseconds(100),
                            TimeSpan.FromMilliseconds(500),
                            TimeSpan.FromSeconds(5));
                    }
                })
                .Start();

            return Tuple.Create(activator, countingTransport);
        }
开发者ID:xenoputtss,项目名称:Rebus,代码行数:32,代码来源:TestCustomizedBackoff.cs


示例17: Main

        static void Main()
        {
            using (var activator = new BuiltinHandlerActivator())
            {
                activator
                    .Register((bus, context) => new TradeCreatedSaga(bus))
                    .Register(() => new SendInvoiceHandler())
                    .Register(() => new TakeOutForManualInspectionHandler());

                Configure.With(activator)
                    .ConfigureEndpoint(Config.Queues.Billing)
                    .Start();

                Task.WaitAll(
                    activator.Bus.Subscribe<TradeCreated>(),
                    activator.Bus.Subscribe<TradeAccepted>(),
                    activator.Bus.Subscribe<TradeRejected>()
                );

                Console.WriteLine("===== Billing =====");

                Console.WriteLine("Press ENTER to quit");
                Console.ReadLine();
            }
        }
开发者ID:rebus-org,项目名称:RebusDemos,代码行数:25,代码来源:Program.cs


示例18: Main

        static void Main()
        {
            // configure Serilog to log with colors in a fairly compact format
            Log.Logger = new LoggerConfiguration()
                .WriteTo.ColoredConsole(outputTemplate: "{Timestamp:HH:mm:ss} {Message}{NewLine}{Exception}")
                .CreateLogger();

            using (var activator = new BuiltinHandlerActivator())
            {
                activator.Register(() => new EventLogger());

                var bus = Configure.With(activator)
                    .ConfigureEndpoint(EndpointRole.Subscriber)
                    .Start();

                Task.WaitAll(
                    bus.Subscribe<AmountsCalculated>(),
                    bus.Subscribe<TaxesCalculated>(),
                    bus.Subscribe<PayoutMethodSelected>(),
                    bus.Subscribe<PayoutReady>(),
                    bus.Subscribe<PayoutNotReady>()
                );

                Console.WriteLine("Press ENTER to quit");
                Console.ReadLine();
            }
        }
开发者ID:rebus-org,项目名称:RebusSamples,代码行数:27,代码来源:Program.cs


示例19: ItWorksWithComplexMessage

        public void ItWorksWithComplexMessage(bool withCompressionEnabled)
        {
            var activator = new BuiltinHandlerActivator();
            var gotIt = new ManualResetEvent(false);

            activator.Handle<TextMessage>(async str =>
            {
                if (string.Equals(str.Text, LongText))
                {
                    gotIt.Set();
                }
                else
                {
                    throw new Exception(string.Format("Received text with {0} chars did not match expected text with {1} chars!",
                        str.Text.Length, LongText.Length));
                }
            });

            Using(activator);

            var bus = CreateBus(withCompressionEnabled, activator);

            bus.SendLocal(new TextMessage {Text = LongText}).Wait();

            gotIt.WaitOrDie(TimeSpan.FromSeconds(10));
        }
开发者ID:nls75,项目名称:Rebus,代码行数:26,代码来源:TestCompressionIntegration.cs


示例20: SetUp

        protected override void SetUp()
        {
            MsmqUtil.Delete(InputQueueName);

            _handlerActivator = new BuiltinHandlerActivator();

            _bus = Configure.With(_handlerActivator)
                .Logging(l => l.Console())
                .Transport(t =>
                {
                    t.UseMsmq(InputQueueName)
                        .OnCreated(queue =>
                        {
                            queue.ResetPermissions();

                            var user = new SecurityIdentifier(WellKnownSidType.WorldSid, null)
                                .Translate(typeof(NTAccount))
                                .ToString();

                            queue.SetPermissions(user, MessageQueueAccessRights.FullControl);
                        });
                })
                .Routing(r => r.TypeBased().Map<string>(InputQueueName))
                .Options(o => o.SetNumberOfWorkers(1))
                .Start();

            Using(_bus);
        }
开发者ID:RichieYang,项目名称:Rebus,代码行数:28,代码来源:TestRequestReply.cs



注:本文中的BuiltinHandlerActivator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BuiltinType类代码示例发布时间:2022-05-24
下一篇:
C# BuiltInType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap