本文整理汇总了C#中EndpointConfiguration.LimitMessageProcessingConcurrencyTo方法的典型用法代码示例。如果您正苦于以下问题:C# EndpointConfiguration.LimitMessageProcessingConcurrencyTo方法的具体用法?C# EndpointConfiguration.LimitMessageProcessingConcurrencyTo怎么用?C# EndpointConfiguration.LimitMessageProcessingConcurrencyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EndpointConfiguration
的用法示例。
在下文中一共展示了EndpointConfiguration.LimitMessageProcessingConcurrencyTo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.Throttling.Limited";
#region LimitConcurrency
var endpointConfiguration = new EndpointConfiguration("Samples.Throttling.Limited");
endpointConfiguration.LimitMessageProcessingConcurrencyTo(1);
#endregion
endpointConfiguration.UsePersistence<InMemoryPersistence>();
endpointConfiguration.SendFailedMessagesTo("error");
#region RegisterBehavior
endpointConfiguration.Pipeline.Register<ThrottlingRegistration>();
#endregion
var endpointInstance = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
try
{
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
await endpointInstance.Stop()
.ConfigureAwait(false);
}
}
示例2: CallbackReceiverMaxConcurrency
void CallbackReceiverMaxConcurrency(EndpointConfiguration endpointConfiguration)
{
#region 3to4rabbitmq-config-callbackreceiver-thread-count
endpointConfiguration.LimitMessageProcessingConcurrencyTo(10);
#endregion
}
示例3: Main
static void Main(string[] args)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
DefaultFactory defaultFactory = LogManager.Use<DefaultFactory>();
defaultFactory.Level(LogLevel.Fatal);
var configuration = new EndpointConfiguration("Chocolate.Facility.Producer");
configuration.UseTransport<MsmqTransport>();
configuration.UsePersistence<InMemoryPersistence>();
configuration.EnableInstallers();
configuration.LimitMessageProcessingConcurrencyTo(Constants.MaxConcurrency);
var bus = Endpoint.Start(configuration).GetAwaiter().GetResult();
stopWatch.Stop();
Console.WriteLine($"Initalizing the bus took { stopWatch.Elapsed.ToString("G")}");
stopWatch.Reset();
stopWatch.Start();
Syncher.SyncEvent.Wait();
stopWatch.Stop();
Console.WriteLine($"Receiving #{ Syncher.SyncEvent.InitialCount } of msgs over the bus took { stopWatch.Elapsed.ToString("G")}");
Console.ReadLine();
}
示例4: ConfigureFromCode
void ConfigureFromCode()
{
#region TuningFromCode
EndpointConfiguration configuration = new EndpointConfiguration();
configuration.LimitMessageProcessingConcurrencyTo(5);
#endregion
}
示例5: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.Throttling";
#region Configuration
EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.Throttling");
endpointConfiguration.LimitMessageProcessingConcurrencyTo(1);
#endregion
endpointConfiguration.UsePersistence<InMemoryPersistence>();
endpointConfiguration.SendFailedMessagesTo("error");
#region RegisterBehavior
endpointConfiguration.Pipeline.Register(
"GitHub API Throttling",
typeof(ThrottlingBehavior),
"implements API throttling for GitHub APIs");
#endregion
IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);
try
{
Console.WriteLine("\r\nPress any key to stop program\r\n");
Console.WriteLine("Sending messages...");
for (int i = 0; i < 100; i++)
{
await endpoint.SendLocal(new SearchGitHub
{
Repository = "NServiceBus",
RepositoryOwner = "Particular",
SearchFor = "IBus"
});
}
Console.WriteLine("Messages sent.");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
await endpoint.Stop();
}
}
示例6: ConcurrencyConfiguration
ConcurrencyConfiguration(EndpointConfiguration endpointConfiguration)
{
#region TuningFromCode
endpointConfiguration.LimitMessageProcessingConcurrencyTo(5);
#endregion
}
示例7: InitBus
private static async Task<IEndpointInstance> InitBus()
{
NServiceBus.Logging.LogManager.Use<NLogFactory>();
var endpoint = ConfigurationManager.AppSettings["endpoint"];
if (string.IsNullOrEmpty(endpoint))
endpoint = "domain";
var config = new EndpointConfiguration(endpoint);
config.MakeInstanceUniquelyAddressable(Defaults.Instance.ToString());
Logger.Info("Initializing Service Bus");
config.LicensePath(ConfigurationManager.AppSettings["license"]);
config.EnableInstallers();
config.LimitMessageProcessingConcurrencyTo(10);
config.UseTransport<RabbitMQTransport>()
//.CallbackReceiverMaxConcurrency(4)
//.UseDirectRoutingTopology()
.ConnectionStringName("RabbitMq")
.PrefetchMultiplier(5)
.TimeToWaitBeforeTriggeringCircuitBreaker(TimeSpan.FromSeconds(30));
config.UseSerialization<NewtonsoftSerializer>();
config.UsePersistence<InMemoryPersistence>();
config.UseContainer<StructureMapBuilder>(c => c.ExistingContainer(_container));
config.SetReadSize(100);
config.ShouldCacheEntities(true);
config.SlowAlertThreshold(1000);
config.SetStreamGenerator((type, bucket, streamid) =>
{
var t = type.FullName.Replace("Pulse.Domain.", "");
return $"{bucket}.[{t}].{streamid}";
});
if (Logger.IsDebugEnabled)
{
config.EnableSlowAlerts(true);
////config.EnableCriticalTimePerformanceCounter();
config.Pipeline.Register(
behavior: typeof(LogIncomingMessageBehavior),
description: "Logs incoming messages"
);
}
config.UseEventStoreDelayedChannel(true);
config.MaxConflictResolves(2);
config.EnableFeature<Aggregates.Domain>();
config.EnableFeature<Aggregates.GetEventStore>();
config.Recoverability().ConfigureForAggregates(5, 3);
//config.EnableFeature<RoutedFeature>();
config.DisableFeature<Sagas>();
return await Endpoint.Start(config).ConfigureAwait(false);
}
示例8: AsyncMain
static async Task AsyncMain()
{
Console.Title = "Samples.MultiTenant.Receiver";
var sharedDatabaseConfiguration = CreateBasicNHibernateConfig();
var tenantDatabasesConfiguration = CreateBasicNHibernateConfig();
var mapper = new ModelMapper();
mapper.AddMapping<OrderMap>();
tenantDatabasesConfiguration.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
var endpointConfiguration = new EndpointConfiguration("Samples.MultiTenant.Receiver");
endpointConfiguration.UseSerialization<JsonSerializer>();
endpointConfiguration.LimitMessageProcessingConcurrencyTo(1);
endpointConfiguration.SendFailedMessagesTo("error");
#region ReceiverConfiguration
var persistence = endpointConfiguration.UsePersistence<NHibernatePersistence>();
persistence.UseConfiguration(tenantDatabasesConfiguration);
persistence.UseSubscriptionStorageConfiguration(sharedDatabaseConfiguration);
persistence.UseTimeoutStorageConfiguration(sharedDatabaseConfiguration);
persistence.DisableSchemaUpdate();
endpointConfiguration.EnableOutbox();
var settingsHolder = endpointConfiguration.GetSettings();
settingsHolder.Set("NHibernate.Timeouts.AutoUpdateSchema", true);
settingsHolder.Set("NHibernate.Subscriptions.AutoUpdateSchema", true);
#endregion
#region ReplaceOpenSqlConnection
endpointConfiguration.Pipeline.Register<ExtractTenantConnectionStringBehavior.Registration>();
#endregion
#region RegisterPropagateTenantIdBehavior
endpointConfiguration.Pipeline.Register<PropagateOutgoingTenantIdBehavior.Registration>();
endpointConfiguration.Pipeline.Register<PropagateIncomingTenantIdBehavior.Registration>();
#endregion
endpointConfiguration.DisableFeature<SecondLevelRetries>();
#region CreateSchema
#endregion
var startableEndpoint = await Endpoint.Create(endpointConfiguration)
.ConfigureAwait(false);
IEndpointInstance endpointInstance = null;
CreateSchema(tenantDatabasesConfiguration, "A");
CreateSchema(tenantDatabasesConfiguration, "B");
try
{
endpointInstance = await startableEndpoint.Start()
.ConfigureAwait(false);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
finally
{
if (endpointInstance != null)
{
await endpointInstance.Stop()
.ConfigureAwait(false);
}
}
}