本文整理汇总了C#中EndpointConfiguration.UnicastRouting方法的典型用法代码示例。如果您正苦于以下问题:C# EndpointConfiguration.UnicastRouting方法的具体用法?C# EndpointConfiguration.UnicastRouting怎么用?C# EndpointConfiguration.UnicastRouting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EndpointConfiguration
的用法示例。
在下文中一共展示了EndpointConfiguration.UnicastRouting方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapPublishers
void MapPublishers(EndpointConfiguration endpointConfiguration)
{
#region PubSub-CodePublisherMapping
endpointConfiguration.UnicastRouting().AddPublisher("Sales", typeof(MyEvent));
endpointConfiguration.UnicastRouting().AddPublisher("Sales", typeof(OtherEvent).Assembly);
#endregion
}
示例2: StaticRoutes
void StaticRoutes(EndpointConfiguration endpointConfiguration)
{
#region Routing-StaticRoutes-Endpoint
endpointConfiguration.UnicastRouting().RouteToEndpoint(typeof(AcceptOrder), "Sales");
#endregion
#region Routing-StaticRoutes-Endpoint-Msmq
endpointConfiguration.UnicastRouting().RouteToEndpoint(typeof(AcceptOrder), "Sales");
#endregion
#region Routing-StaticRoutes-Endpoint-Broker
endpointConfiguration.UnicastRouting().RouteToEndpoint(typeof(AcceptOrder), "Sales");
#endregion
#region Routing-StaticRoutes-Address
endpointConfiguration.UnicastRouting().Mapping.Logical
.RouteToAddress(typeof(AcceptOrder), "[email protected]");
#endregion
}
示例3: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.SenderSideScaleOut.UnawareCilent";
EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.SenderSideScaleOut.UnawareCilent");
endpointConfiguration.UsePersistence<InMemoryPersistence>();
endpointConfiguration.SendFailedMessagesTo("error");
endpointConfiguration.UnicastRouting()
.RouteToEndpoint(typeof(DoSomething), "Samples.SenderSideScaleOut.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: CustomRoutingStore
void CustomRoutingStore(EndpointConfiguration endpointConfiguration)
{
#region Routing-CustomRoutingStore
endpointConfiguration.UnicastRouting().Mapping.Logical.AddDynamic((t, c) =>
LoadFromCache(t) ?? LoadFromDatabaseAndPutToCache(t));
#endregion
}
示例5: StaticEndpointMapping
void StaticEndpointMapping(EndpointConfiguration endpointConfiguration)
{
#region Routing-StaticEndpointMapping
EndpointName sales = new EndpointName("Sales");
endpointConfiguration.UnicastRouting().Mapping.Physical
.Add(sales,
new EndpointInstance(sales, "1", null),
new EndpointInstance(sales, "2", null));
#endregion
}
示例6: InputQueueOverrideRouting
void InputQueueOverrideRouting(EndpointConfiguration endpointConfiguration)
{
#region InputQueueOverrideRouting
var unicastRouting = endpointConfiguration.UnicastRouting();
unicastRouting.RouteToEndpoint(typeof(MyMessage), "MyEndpoint");
var transport = endpointConfiguration.UseTransport<MyTransport>();
transport.AddAddressTranslationException(
new EndpointInstance("MyEndpoint"), "MyEndpoint.Messages");
#endregion
}
示例7: DynamicRoutes
void DynamicRoutes(EndpointConfiguration endpointConfiguration)
{
#region Routing-DynamicRoutes
endpointConfiguration.UnicastRouting().Mapping.Logical
.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
}
示例8: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.SenderSideScaleOut.AwareClient";
var endpointConfiguration = new EndpointConfiguration("Samples.SenderSideScaleOut.AwareClient");
endpointConfiguration.UsePersistence<InMemoryPersistence>();
endpointConfiguration.SendFailedMessagesTo("error");
#region Logical-Routing
var routing = endpointConfiguration.UnicastRouting();
routing.RouteToEndpoint(typeof(DoSomething), "Samples.SenderSideScaleOut.Server");
#endregion
#region File-Based-Routing
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.DistributeMessagesUsingFileBasedEndpointInstanceMapping("routes.xml");
#endregion
var endpointInstance = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
Console.WriteLine("Press enter to send a message");
Console.WriteLine("Press any key to exit");
var sequenceId = 0;
while (true)
{
var key = Console.ReadKey();
if (key.Key != ConsoleKey.Enter)
{
break;
}
var command = new DoSomething { SequenceId = ++sequenceId };
await endpointInstance.Send(command)
.ConfigureAwait(false);
Console.WriteLine($"Message {command.SequenceId} Sent");
}
await endpointInstance.Stop()
.ConfigureAwait(false);
}
示例9: Usage
Usage()
{
#region EndpointNameCode
EndpointConfiguration endpointConfiguration = new EndpointConfiguration("MyEndpoint");
#endregion
#region InputQueueName
endpointConfiguration.UseTransport<MyTransport>().AddAddressTranslationException(
new EndpointInstance("MyEndpoint"), "MyEndpoint.Messages");
#endregion
#region InputQueueOverrideRouting
endpointConfiguration.UnicastRouting().RouteToEndpoint(typeof(MyMessage), "MyEndpoint");
endpointConfiguration.UseTransport<MyTransport>().AddAddressTranslationException(
new EndpointInstance("MyEndpoint"), "MyEndpoint.Messages");
#endregion
}
示例10: DynamicEndpointMapping
void DynamicEndpointMapping(EndpointConfiguration endpointConfiguration)
{
#region Routing-DynamicEndpointMapping
endpointConfiguration.UnicastRouting().Mapping.Physical.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
}
示例11: FileBasedRoutingAdvanced
public void FileBasedRoutingAdvanced()
{
EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Endpoint");
#region Routing-FileBased-ConfigAdvanced
endpointConfiguration.UnicastRouting().Mapping
.DistributeMessagesUsingFileBasedEndpointInstanceMapping(@"C:\Routes.xml");
#endregion
}
示例12: FileBasedRouting
void FileBasedRouting(EndpointConfiguration endpointConfiguration)
{
#region Routing-FileBased-Config
endpointConfiguration.UnicastRouting().RouteToEndpoint(typeof(AcceptOrder), "Sales");
endpointConfiguration.UnicastRouting().RouteToEndpoint(typeof(SendOrder), "Shipping");
endpointConfiguration.UseTransport<MsmqTransport>()
.DistributeMessagesUsingFileBasedEndpointInstanceMapping(@"C:\Routes.xml");
#endregion
}