当前位置: 首页>>代码示例>>C#>>正文


C# EndpointConfiguration.Routing方法代码示例

本文整理汇总了C#中EndpointConfiguration.Routing方法的典型用法代码示例。如果您正苦于以下问题:C# EndpointConfiguration.Routing方法的具体用法?C# EndpointConfiguration.Routing怎么用?C# EndpointConfiguration.Routing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EndpointConfiguration的用法示例。


在下文中一共展示了EndpointConfiguration.Routing方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainAsync

        private static async Task MainAsync()
        {
            var factory = LogManager.Use<DefaultFactory>();
            factory.Level(LogLevel.Debug);

            var configuration = new EndpointConfiguration();
            configuration.EndpointName("Sender");
            configuration.EnableInstallers();
            configuration.UseSerialization<JsonSerializer>();
            configuration.UsePersistence<InMemoryPersistence>();

            configuration.SendFailedMessagesTo("error");
           
            var transportConfiguration = configuration.UseTransport<AzureServiceBusTransport>();

            transportConfiguration.ConnectionString(Environment.GetEnvironmentVariable("AzureServiceBus.ConnectionString"));


            // define routing (what used to be message endpoint mapping)
            var endpointName = new EndpointName("Receiver");
           // configuration.Routing().SetMessageDistributionStrategy(new SingleInstanceRoundRobinDistributionStrategy(), t => true);
            configuration.Routing().UnicastRoutingTable.RouteToEndpoint(typeof(TestCommand), endpointName);
            configuration.Routing().EndpointInstances.AddStatic(endpointName, new EndpointInstance(endpointName, null, null));

            var endpoint = await Endpoint.Start(configuration);

            Console.WriteLine("Press ESC to exit, any other key to send a message");
            Console.WriteLine("Press any other key to send a message");
            while (Console.ReadKey().Key != ConsoleKey.Escape)
            {
                await endpoint.Send<TestCommand>(m => m.Data = "Testing ASB send");
                Console.WriteLine("message sent");
            }
        }
开发者ID:SeanFeldman,项目名称:ASB.v7.Tester,代码行数:34,代码来源:Program.cs

示例2: StaticRoutes

        public void StaticRoutes()
        {
            EndpointConfiguration configuration = new EndpointConfiguration();
            #region Routing-StaticRoutes-Endpoint
            configuration.Routing().UnicastRoutingTable.RouteToEndpoint(typeof(AcceptOrder), "Sales");
            #endregion

            #region Routing-StaticRoutes-Address
            configuration.Routing().UnicastRoutingTable.RouteToAddress(typeof(AcceptOrder), "[email protected]");
            #endregion
        }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:11,代码来源:RoutingAPIs.cs

示例3: AsyncMain

    static async Task AsyncMain()
    {
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration();
        endpointConfiguration.UsePersistence<InMemoryPersistence>();
        endpointConfiguration.SendFailedMessagesTo("error");

        endpointConfiguration.Routing()
            .UnicastRoutingTable
            .RouteToEndpoint(typeof(DoSomething), "Server");

        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
        Console.WriteLine("Press enter to send a message");
        Console.WriteLine("Press any key to exit");
        while (true)
        {
            ConsoleKeyInfo key = Console.ReadKey();
            if (key.Key != ConsoleKey.Enter)
            {
                break;
            }
            await endpoint.Send(new DoSomething());
            Console.WriteLine("Message Sent");
        }
        await endpoint.Stop();
    }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:25,代码来源:Program.cs

示例4: StaticEndpointMapping

 public void StaticEndpointMapping()
 {
     EndpointConfiguration configuration = new EndpointConfiguration();
     #region Routing-StaticEndpointMapping
     EndpointName sales = new EndpointName("Sales");
     configuration.Routing().EndpointInstances
         .AddStatic(sales, new EndpointInstance(sales, "1", null), new EndpointInstance(sales, "2", null));
     #endregion
 }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:9,代码来源:RoutingAPIs.cs

示例5: CustomRoutingStore

        public void CustomRoutingStore()
        {
            EndpointConfiguration configuration = new EndpointConfiguration();

            #region Routing-CustomRoutingStore

            configuration.Routing().UnicastRoutingTable.AddDynamic((t, c) =>
                LoadFromCache(t) ?? LoadFromDatabaseAndPutToCache(t));

            #endregion
        }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:11,代码来源:RoutingAPIs.cs

示例6: DynamicRoutes

 public void DynamicRoutes()
 {
     EndpointConfiguration configuration = new EndpointConfiguration();
     #region Routing-DynamicRoutes
     configuration.Routing().UnicastRoutingTable
         .AddDynamic((types, contextBag) => new[]
         {
             //Use endpoint name
             new UnicastRoute("Sales"),
             //Use endpoint instance name
             new UnicastRoute(new EndpointInstance("Sales", "1")),
             //Use transport address (e.g. MSMQ)
             new UnicastRoute("[email protected]")
         });
     #endregion
 }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:16,代码来源:RoutingAPIs.cs

示例7: DynamicEndpointMapping

        public void DynamicEndpointMapping()
        {
            EndpointConfiguration configuration = new EndpointConfiguration();

            #region Routing-DynamicEndpointMapping

            configuration.Routing().EndpointInstances.AddDynamic(async e =>
            {
                if (e.ToString().StartsWith("Sales"))
                {
                    return new[]
                    {
                        new EndpointInstance(e, "1").SetProperty("SomeProp", "SomeValue"),
                        new EndpointInstance(e, "2").AtMachine("B")
                    };
                }
                return null;
            });

            #endregion
        }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:21,代码来源:RoutingAPIs.cs

示例8: FileBasedRouting

 public void FileBasedRouting()
 {
     EndpointConfiguration configuration = new EndpointConfiguration();
     #region Routing-FileBased-Config
     configuration.Routing().UnicastRoutingTable.RouteToEndpoint(typeof(AcceptOrder), "Sales");
     configuration.Routing().UnicastRoutingTable.RouteToEndpoint(typeof(SendOrder), "Shipping");
     configuration.Routing().UseFileBasedEndpointInstanceMapping(@"C:\Routes.xml");
     #endregion
 }
开发者ID:fivec,项目名称:docs.particular.net,代码行数:9,代码来源:RoutingAPIs.cs


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