本文整理汇总了C#中NServiceBus.Features.FeatureConfigurationContext类的典型用法代码示例。如果您正苦于以下问题:C# FeatureConfigurationContext类的具体用法?C# FeatureConfigurationContext怎么用?C# FeatureConfigurationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FeatureConfigurationContext类属于NServiceBus.Features命名空间,在下文中一共展示了FeatureConfigurationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
/// <summary>
/// Called when the features is activated
/// </summary>
/// <param name="context">
/// The context.
/// </param>
protected override void Setup(FeatureConfigurationContext context)
{
TimeoutClassMaps.ConfigureClassMaps();
context.Container.ConfigureComponent<MongoTimeoutPersister>(DependencyLifecycle.SingleInstance)
.ConfigureProperty(x => x.EndpointName, context.Settings.EndpointName());
}
示例2: SetTransportThresholds
void SetTransportThresholds(FeatureConfigurationContext context)
{
var transportConfig = context.Settings.GetConfigSection<TransportConfig>();
var maximumThroughput = 0;
var maximumNumberOfRetries = 5;
var maximumConcurrencyLevel = 1;
if (transportConfig != null)
{
maximumNumberOfRetries = transportConfig.MaxRetries;
maximumThroughput = transportConfig.MaximumMessageThroughputPerSecond;
maximumConcurrencyLevel = transportConfig.MaximumConcurrencyLevel;
}
var transactionSettings = new TransactionSettings(context.Settings)
{
MaxRetries = maximumNumberOfRetries
};
context.Container.ConfigureComponent(b => new TransportReceiver(transactionSettings, maximumConcurrencyLevel, maximumThroughput, b.Build<IDequeueMessages>(), b.Build<IManageMessageFailures>(), context.Settings, b.Build<Configure>())
{
CriticalError = b.Build<CriticalError>(),
Notifications = b.Build<BusNotifications>()
}, DependencyLifecycle.InstancePerCall);
}
示例3: Setup
/// <summary>
/// Called when the feature should perform its initialization. This call will only happen if the feature is enabled.
/// </summary>
protected override void Setup(FeatureConfigurationContext context)
{
context.Settings.Get<SharedMappings>()
.AddMapping(ApplyMappings);
context.Container.ConfigureComponent<OutboxPersister>(DependencyLifecycle.SingleInstance);
}
示例4: Setup
/// <summary>
/// See <see cref="Feature.Setup"/>
/// </summary>
protected internal override void Setup(FeatureConfigurationContext context)
{
var processorAddress = context.Settings.LocalAddress().SubScope("Retries");
var useRemoteRetryProcessor = context.Settings.HasSetting("SecondLevelRetries.AddressOfRetryProcessor");
if (useRemoteRetryProcessor)
{
processorAddress = context.Settings.Get<Address>("SecondLevelRetries.AddressOfRetryProcessor");
}
var container = context.Container;
container.ConfigureProperty<FaultManager>(fm => fm.RetriesErrorQueue, processorAddress);
container.ConfigureProperty<SecondLevelRetriesProcessor>(rs => rs.InputAddress, processorAddress);
var retryPolicy = context.Settings.GetOrDefault<Func<TransportMessage, TimeSpan>>("SecondLevelRetries.RetryPolicy");
if (retryPolicy != null)
{
container.ConfigureProperty<SecondLevelRetriesProcessor>(rs => rs.RetryPolicy, retryPolicy);
}
container.ConfigureProperty<SecondLevelRetriesProcessor>(rs => rs.Disabled, useRemoteRetryProcessor);
var retriesConfig = context.Settings.GetConfigSection<SecondLevelRetriesConfig>();
if (retriesConfig == null)
return;
container.ConfigureProperty<SecondLevelRetriesProcessor>(rs => rs.NumberOfRetries, retriesConfig.NumberOfRetries);
if (retriesConfig.TimeIncrease != TimeSpan.MinValue)
{
container.ConfigureProperty<SecondLevelRetriesProcessor>(rs => rs.TimeIncrease, retriesConfig.TimeIncrease);
}
}
示例5: Setup
/// <summary>
/// See <see cref="Feature.Setup"/>
/// </summary>
protected internal override void Setup(FeatureConfigurationContext context)
{
// If Audit feature is enabled and the value not specified via config and instead specified in the registry:
// Log a warning when running in the debugger to remind user to make sure the
// production machine will need to have the required registry setting.
if (Debugger.IsAttached && GetAuditQueueAddressFromAuditConfig(context) == Address.Undefined)
{
Logger.Warn("Endpoint auditing is configured using the registry on this machine, please ensure that you either run Set-NServiceBusLocalMachineSettings cmdlet on the target deployment machine or specify the QueueName attribute in the AuditConfig section in your app.config file. To quickly add the AuditConfig section to your app.config, in Package Manager Console type: add-NServiceBusAuditConfig.");
}
context.Pipeline.Register<AuditBehavior.Registration>();
var auditQueue = GetConfiguredAuditQueue(context);
context.Container.ConfigureComponent<AuditQueueCreator>(DependencyLifecycle.InstancePerCall)
.ConfigureProperty(p => p.Enabled, true)
.ConfigureProperty(t => t.AuditQueue, auditQueue);
var behaviorConfig = context.Container.ConfigureComponent<AuditBehavior>(DependencyLifecycle.InstancePerCall)
.ConfigureProperty(p => p.AuditQueue, auditQueue);
var messageAuditingConfig = context.Settings.GetConfigSection<AuditConfig>();
if (messageAuditingConfig != null && messageAuditingConfig.OverrideTimeToBeReceived > TimeSpan.Zero)
{
behaviorConfig.ConfigureProperty(t => t.TimeToBeReceivedOnForwardedMessages, messageAuditingConfig.OverrideTimeToBeReceived);
}
}
示例6: Setup
/// <summary>
/// Invoked if the feature is activated
/// </summary>
/// <param name="context">The feature context</param>
protected internal override void Setup(FeatureConfigurationContext context)
{
var queueName = context.Settings.GetOrDefault<string>("MsmqSubscriptionPersistence.QueueName");
var cfg = context.Settings.GetConfigSection<MsmqSubscriptionStorageConfig>();
if (string.IsNullOrEmpty(queueName))
{
if (cfg == null)
{
Logger.Warn("Could not find configuration section for Msmq Subscription Storage and no name was specified for this endpoint. Going to default the subscription queue");
queueName = "NServiceBus.Subscriptions";
}
else
{
queueName = cfg.Queue;
}
}
var storageQueue = Address.Parse(queueName);
context.Container.ConfigureComponent<SubscriptionsQueueCreator>(DependencyLifecycle.InstancePerCall)
.ConfigureProperty(t => t.StorageQueue, storageQueue);
context.Container.ConfigureComponent<MsmqSubscriptionStorage>(DependencyLifecycle.SingleInstance)
.ConfigureProperty(s => s.Queue, storageQueue)
.ConfigureProperty(s => s.TransactionsEnabled, context.Settings.Get<bool>("Transactions.Enabled"));
}
示例7: Setup
protected override void Setup(FeatureConfigurationContext context)
{
PipelineSettings pipeline = context.Pipeline;
pipeline.Replace("NServiceBus.DeserializeLogicalMessagesConnector", typeof(DeserializeConnector));
pipeline.Replace("NServiceBus.SerializeMessageConnector", typeof(SerializeConnector));
context.Container.ConfigureComponent<SerializationMapper>(DependencyLifecycle.SingleInstance);
}
示例8: RequireOutboxConsent
static bool RequireOutboxConsent(FeatureConfigurationContext context)
{
if (context.Settings.GetOrDefault<bool>("DisableOutboxTransportCheck"))
{
return true;
}
var configValue = ConfigurationManager.AppSettings.Get("NServiceBus/Outbox");
if (configValue == null)
{
throw new Exception(@"To use the Outbox feature with MSMQ or SQLServer transports it must be enabled in the config file.
To do that add the following:
<appSettings>
<add key=""NServiceBus/Outbox"" value=""true""/>
</appSettings>
The reason this is required is to ensure that all the guidelines regarding this feature have been understood and know the limitations when running under MSMQ or SQLServer transports.");
}
bool result;
if (!bool.TryParse(configValue, out result))
{
throw new Exception("Invalid value in \"NServiceBus/Outbox\" AppSetting. Ensure it is either \"true\" or \"false\".");
}
return result;
}
示例9: RequireOutboxConsent
static bool RequireOutboxConsent(FeatureConfigurationContext context)
{
if (context.Settings.GetOrDefault<bool>("DisableOutboxTransportCheck"))
{
return true;
}
var configValue = ConfigurationManager.AppSettings.Get("NServiceBus/Outbox");
if (configValue == null)
{
throw new Exception(@"To use the Outbox feature with MSMQ or SQLServer transports you need to enable it in your config file.
To do that add the following:
<appSettings>
<add key=""NServiceBus/Outbox"" value=""true""/>
</appSettings>
The reason you need to do this is because we need to ensure that you have read all the documentation regarding this feature and know the limitations when running it under MSMQ or SQLServer transports.");
}
bool result;
if (!Boolean.TryParse(configValue, out result))
{
throw new Exception("Invalid value in \"NServiceBus/Outbox\" AppSetting. Please ensure it is either \"true\" or \"false\".");
}
return result;
}
示例10: Setup
protected internal override void Setup(FeatureConfigurationContext context)
{
context.Pipeline.Register("TransportReceiveToPhysicalMessageProcessingConnector", b => b.Build<TransportReceiveToPhysicalMessageProcessingConnector>(), "Allows to abort processing the message");
context.Pipeline.Register("LoadHandlersConnector", b => b.Build<LoadHandlersConnector>(), "Gets all the handlers to invoke from the MessageHandler registry based on the message type.");
var hasUnitsOfWork = context.Container.HasComponent<IManageUnitsOfWork>();
context.Pipeline.Register("ExecuteUnitOfWork", new UnitOfWorkBehavior(hasUnitsOfWork), "Executes the UoW");
var hasIncomingTransportMessageMutators = context.Container.HasComponent<IMutateIncomingTransportMessages>();
context.Pipeline.Register("MutateIncomingTransportMessage", new MutateIncomingTransportMessageBehavior(hasIncomingTransportMessageMutators), "Executes IMutateIncomingTransportMessages");
var hasIncomingMessageMutators = context.Container.HasComponent<IMutateIncomingMessages>();
context.Pipeline.Register("MutateIncomingMessages", new MutateIncomingMessageBehavior(hasIncomingMessageMutators), "Executes IMutateIncomingMessages");
context.Pipeline.Register("InvokeHandlers", new InvokeHandlerTerminator(), "Calls the IHandleMessages<T>.Handle(T)");
context.Container.ConfigureComponent(b =>
{
var storage = context.Container.HasComponent<IOutboxStorage>() ? b.Build<IOutboxStorage>() : new NoOpOutbox();
return new TransportReceiveToPhysicalMessageProcessingConnector(storage);
}, DependencyLifecycle.InstancePerCall);
context.Container.ConfigureComponent(b =>
{
var adapter = context.Container.HasComponent<ISynchronizedStorageAdapter>() ? b.Build<ISynchronizedStorageAdapter>() : new NoOpAdaper();
var syncStorage = context.Container.HasComponent<ISynchronizedStorage>() ? b.Build<ISynchronizedStorage>() : new NoOpSynchronizedStorage();
return new LoadHandlersConnector(b.Build<MessageHandlerRegistry>(), syncStorage, adapter);
}, DependencyLifecycle.InstancePerCall);
}
示例11: Configure
/// <summary>
/// Initializes a new instance of <see cref="ConfigureTransport"/>.
/// </summary>
protected override void Configure(FeatureConfigurationContext context, string connectionString)
{
new CheckMachineNameForComplianceWithDtcLimitation()
.Check();
context.Container.ConfigureComponent<CorrelationIdMutatorForBackwardsCompatibilityWithV3>(DependencyLifecycle.InstancePerCall);
context.Container.ConfigureComponent<MsmqUnitOfWork>(DependencyLifecycle.SingleInstance);
context.Container.ConfigureComponent<MsmqDequeueStrategy>(DependencyLifecycle.InstancePerCall);
var cfg = context.Settings.GetConfigSection<MsmqMessageQueueConfig>();
var settings = new MsmqSettings();
if (cfg != null)
{
settings.UseJournalQueue = cfg.UseJournalQueue;
settings.UseDeadLetterQueue = cfg.UseDeadLetterQueue;
Logger.Warn(Message);
}
else
{
if (connectionString != null)
{
settings = new MsmqConnectionStringBuilder(connectionString).RetrieveSettings();
}
}
context.Container.ConfigureComponent<MsmqMessageSender>(DependencyLifecycle.InstancePerCall)
.ConfigureProperty(t => t.Settings, settings)
.ConfigureProperty(t => t.SuppressDistributedTransactions, context.Settings.Get<bool>("Transactions.SuppressDistributedTransactions"));
context.Container.ConfigureComponent<MsmqQueueCreator>(DependencyLifecycle.InstancePerCall)
.ConfigureProperty(t => t.Settings, settings);
}
示例12: Setup
/// <summary>
/// See <see cref="Feature.Setup" />.
/// </summary>
protected internal override void Setup(FeatureConfigurationContext context)
{
context.Pipeline.Register(new AuditToDispatchConnector(auditConfig.TimeToBeReceived), "Dispatches the audit message to the transport");
context.Pipeline.Register("AuditProcessedMessage", new InvokeAuditPipelineBehavior(auditConfig.Address), "Execute the audit pipeline");
context.Settings.Get<QueueBindings>().BindSending(auditConfig.Address);
}
示例13: Setup
protected override void Setup(FeatureConfigurationContext context)
{
context.Pipeline.Replace(WellKnownStep.DeserializeMessages, typeof(DeserializeBehavior));
context.Pipeline.Replace(WellKnownStep.SerializeMessage, typeof(SerializeBehavior));
context.Container.ConfigureComponent<SerializationMapper>(DependencyLifecycle.SingleInstance);
}
示例14: VerifyPrerequisite
bool VerifyPrerequisite(FeatureConfigurationContext context)
{
var encryptedProperties = GetEncryptedProperties(context);
var encryptionServiceConstructorDefined = context.Settings.GetEncryptionServiceConstructor(out serviceConstructor);
var encryptionPropertiesFound = encryptedProperties.Any();
if (encryptionPropertiesFound)
{
if (!encryptionServiceConstructorDefined)
{
var stringBuilder = new StringBuilder("Encrypted properties were found but no encryption service has been defined. Please call ConfigurationBuilder.RijndaelEncryptionService or ConfigurationBuilder.RegisterEncryptionService. Encrypted properties: ");
foreach (var encryptedProperty in encryptedProperties)
{
stringBuilder.AppendFormat("{0}.{1}\r\n", encryptedProperty.DeclaringType, encryptedProperty.Name);
}
throw new Exception(stringBuilder.ToString());
}
}
else
{
if (encryptionServiceConstructorDefined)
{
var message =
@"You have configured a encryption service via either ConfigurationBuilder.RijndaelEncryptionService or ConfigurationBuilder.RegisterEncryptionService however no properties were found on type that require encryption.
Perhaps you forgot to define your encryption message conventions or to define message properties using as WireEncryptedString.";
log.Warn(message);
}
}
return encryptionPropertiesFound;
}
示例15: Configure
public override void Configure(FeatureConfigurationContext context, string connectionStringWithSchema)
{
context.Pipeline.Register<ReadIncomingCallbackAddressBehavior.Registration>();
var useCallbackReceiver = context.Settings.Get<bool>(UseCallbackReceiverSettingKey);
var maxConcurrencyForCallbackReceiver = context.Settings.Get<int>(MaxConcurrencyForCallbackReceiverSettingKey);
var queueName = context.Settings.EndpointName();
var callbackQueue = string.Format("{0}.{1}", queueName, RuntimeEnvironment.MachineName);
if (useCallbackReceiver)
{
var callbackAddress = Address.Parse(callbackQueue);
context.Container.ConfigureComponent<CallbackQueueCreator>(DependencyLifecycle.InstancePerCall)
.ConfigureProperty(p => p.Enabled, true)
.ConfigureProperty(p => p.CallbackQueueAddress, callbackAddress);
context.Pipeline.Register<SetOutgoingCallbackAddressBehavior.Registration>();
context.Container.ConfigureComponent(c => new OutgoingCallbackAddressSetter(callbackQueue), DependencyLifecycle.SingleInstance);
}
context.Container.RegisterSingleton(new SecondaryReceiveConfiguration(workQueue =>
{
//if this isn't the main queue we shouldn't use callback receiver
if (!useCallbackReceiver || workQueue != queueName)
{
return SecondaryReceiveSettings.Disabled();
}
return SecondaryReceiveSettings.Enabled(callbackQueue, maxConcurrencyForCallbackReceiver);
}));
}