本文整理汇总了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");
}
}
示例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
}
示例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();
}
示例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
}
示例5: CustomRoutingStore
public void CustomRoutingStore()
{
EndpointConfiguration configuration = new EndpointConfiguration();
#region Routing-CustomRoutingStore
configuration.Routing().UnicastRoutingTable.AddDynamic((t, c) =>
LoadFromCache(t) ?? LoadFromDatabaseAndPutToCache(t));
#endregion
}
示例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
}
示例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
}
示例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
}