/// <summary> /// Initializes the <see cref="IDequeueMessages"/>. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="transactionSettings">The <see cref="TransactionSettings"/> to be used by <see cref="IDequeueMessages"/>.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage">Needs to be called by <see cref="IDequeueMessages"/> after the message has been processed regardless if the outcome was successful or not.</param> public void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage) { settings = transactionSettings; this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; this.address = address; }
/// <summary> /// Initializes the <see cref="IDequeueMessages"/>. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="transactionSettings">The <see cref="TransactionSettings"/> to be used by <see cref="IDequeueMessages"/>.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage">Needs to be called by <see cref="IDequeueMessages"/> after the message has been processed regardless if the outcome was successful or not.</param> public void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage) { this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; workQueue = address.Queue; autoAck = !transactionSettings.IsTransactional; }
public void Init(TransactionSettings settings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { this.settings = settings; this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; }
/// <summary> /// Initializes the <see cref="IDequeueMessages"/>. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="transactionSettings">The <see cref="TransactionSettings"/> to be used by <see cref="IDequeueMessages"/>.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage">Needs to be called by <see cref="IDequeueMessages"/> after the message has been processed regardless if the outcome was successful or not.</param> public void Init(Address address, TransactionSettings transactionSettings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; workQueue = address.Queue; autoAck = !transactionSettings.IsTransactional; }
private void VerifyAllReceiversAreStarted(Address address, TransactionSettings settings) { foreach (var messageReceiver in messageReceivers) { messageReceiver.Verify(mr => mr.Start(address, settings)); } }
/// <summary> /// Initializes the <see cref="IDequeueMessages" />. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="transactionSettings">The <see cref="TransactionSettings" /> to be used by <see cref="IDequeueMessages" />.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage">Needs to be called by <see cref="IDequeueMessages" /> after the message has been processed regardless if the outcome was successful or not.</param> public void Init(Address address, TransactionSettings transactionSettings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; this.workQueue = this.NamePolicy.GetQueueName(address); this.clientInfo = string.Format("OracleAQDequeueStrategy for {0}", this.workQueue); this.transactionOptions = new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout, }; this.dequeueOptions = new OracleAQDequeueOptions { DequeueMode = OracleAQDequeueMode.Remove, ProviderSpecificType = true, Wait = 0, }; if (this.PurgeOnStartup) { this.Purger.Purge(this.workQueue); } }
/// <summary> /// Initializes the <see cref="IDequeueMessages"/>. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="transactionSettings">The <see cref="TransactionSettings"/> to be used by <see cref="IDequeueMessages"/>.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage">Needs to be called by <see cref="IDequeueMessages"/> after the message has been processed regardless if the outcome was successful or not.</param> public void Init(Address address, TransactionSettings transactionSettings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { settings = transactionSettings; this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; this.address = address; }
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); }
void SuppressDistributedTransactions(TransactionSettings transactionSettings) { #region 5to6SuppressDistributedTransactions bool suppressDistributedTransactions = transactionSettings.SuppressDistributedTransactions; #endregion }
/// <summary> /// Convert a saveBundle into a SaveMap /// </summary> public static Dictionary <Type, List <EntityInfo> > Convert(JObject saveBundle, TransactionSettings transactionSettings = null) { var dynSaveBundle = (dynamic)saveBundle; var entitiesArray = (JArray)dynSaveBundle.entities; var saveWorkState = new SaveWorkState(_provider, entitiesArray); return(saveWorkState.SaveMap); }
void IsTransactional(TransactionSettings transactionSettings) { #region 5to6IsTransactional bool isTransactional = transactionSettings.IsTransactional; #endregion }
public Breeze.ContextProvider.SaveResult Commit(Newtonsoft.Json.Linq.JObject changeSet) { TransactionSettings transactionSettings = new TransactionSettings() { TransactionType = TransactionType.TransactionScope }; return(contextProvider.SaveChanges(changeSet, transactionSettings)); }
public SaveResult SaveWithNoTransaction([FromBody] JObject saveBundle) { var txSettings = new TransactionSettings() { TransactionType = TransactionType.None }; return(PersistenceManager.SaveChanges(saveBundle, txSettings)); }
/// <summary> /// Базовая инициализация экземпляра /// </summary> bool Init() { //инициализация настроек var s = TransactionSettings.Load(); Settings = s.CurrentCollection; return(Validate(Settings)); }
public SaveResult SaveWithTransactionScope(JObject saveBundle) { var txSettings = new TransactionSettings() { TransactionType = TransactionType.TransactionScope }; return(ContextProvider.SaveChanges(saveBundle, txSettings)); }
/// <summary> /// Initializes the <see cref="IDequeueMessages"/>. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="transactionSettings">The <see cref="TransactionSettings"/> to be used by <see cref="IDequeueMessages"/>.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage">Needs to be called by <see cref="IDequeueMessages"/> after the message has been processed regardless if the outcome was successful or not.</param> public virtual void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage) { settings = transactionSettings; this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; this.address = address; transactionOptions = new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout }; }
public void Init(Address address, TransactionSettings transactionSettings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { //todo: handle all local queues through one loop? _address = address; _endProcessMessage = endProcessMessage; _tryProcessMessage = tryProcessMessage; }
public SaveResult SaveChanges(JObject saveBundle) { // before, save and after done in one transaction var txSettings = new TransactionSettings() { TransactionType = TransactionType.DbTransaction }; return(this._context.SaveChanges(saveBundle, txSettings)); }
public void SuppressDistributedTransactions() { TransactionSettings transactionSettings = null; #region 5to6SuppressDistributedTransactions bool suppressDistributedTransactions = transactionSettings.SuppressDistributedTransactions; #endregion }
public void IsTransactional() { TransactionSettings transactionSettings = null; #region 5to6IsTransactional bool isTransactional = transactionSettings.IsTransactional; #endregion }
/// <summary> /// Initializes the <see cref="IDequeueMessages"/>. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="transactionSettings">The <see cref="TransactionSettings"/> to be used by <see cref="IDequeueMessages"/>.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage">Needs to be called by <see cref="IDequeueMessages"/> after the message has been processed regardless if the outcome was successful or not.</param> public void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage) { this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; addressToPoll = address; settings = transactionSettings; transactionOptions = new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout }; MessageReceiver.Init(addressToPoll, settings.IsTransactional); }
/// <summary> /// Initializes the <see cref="IDequeueMessages"/>. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="transactionSettings">The <see cref="TransactionSettings"/> to be used by <see cref="IDequeueMessages"/>.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage">Needs to be called by <see cref="IDequeueMessages"/> after the message has been processed regardless if the outcome was successful or not.</param> public virtual void Init(Address address, TransactionSettings transactionSettings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { settings = transactionSettings; this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; this.address = address; transactionOptions = new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout }; }
public void Start(Address address, TransactionSettings transactionSettings) { messageProcessor.Start(transactionSettings); defaultConsumer = messageProcessor.CreateMessageConsumer("queue://" + address.Queue); defaultConsumer.Listener += messageProcessor.ProcessMessage; if (address == Address.Local) { eventConsumer.Start(); } }
/// <summary> /// Initializes the <see cref="IDequeueMessages" />. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="settings">The <see cref="TransactionSettings" /> to be used by <see cref="IDequeueMessages" />.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage"> /// Needs to be called by <see cref="IDequeueMessages" /> after the message has been /// processed regardless if the outcome was successful or not. /// </param> public void Init(Address address, TransactionSettings settings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; transactionSettings = settings; if (address == null) { throw new ArgumentException("Input queue must be specified"); } if (!address.Machine.Equals(RuntimeEnvironment.MachineName, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException( string.Format("Input queue [{0}] must be on the same machine as this process [{1}].", address, RuntimeEnvironment.MachineName)); } transactionOptions = new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout }; queue = new MessageQueue(MsmqUtilities.GetFullPath(address), false, true, QueueAccessMode.Receive); if (transactionSettings.IsTransactional && !QueueIsTransactional()) { throw new ArgumentException( "Queue must be transactional if you configure your endpoint to be transactional (" + address + ")."); } var messageReadPropertyFilter = new MessagePropertyFilter { Body = true, TimeToBeReceived = true, Recoverable = true, Id = true, ResponseQueue = true, CorrelationId = true, Extension = true, AppSpecific = true }; queue.MessageReadPropertyFilter = messageReadPropertyFilter; if (PurgeOnStartup) { queue.Purge(); } }
/// <summary> /// Initializes the <see cref="IDequeueMessages" />. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="settings">The <see cref="TransactionSettings" /> to be used by <see cref="IDequeueMessages" />.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage"> /// Needs to be called by <see cref="IDequeueMessages" /> after the message has been /// processed regardless if the outcome was successful or not. /// </param> public void Init(Address address, TransactionSettings settings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage) { this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; transactionSettings = settings; if (address == null) { throw new ArgumentException("Input queue must be specified"); } if (!address.Machine.Equals(RuntimeEnvironment.MachineName, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException( string.Format("Input queue [{0}] must be on the same machine as this process [{1}].", address, RuntimeEnvironment.MachineName)); } transactionOptions = new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout }; queue = new MessageQueue(MsmqUtilities.GetFullPath(address), false, true, QueueAccessMode.Receive); if (transactionSettings.IsTransactional && !QueueIsTransactional()) { throw new ArgumentException( "Queue must be transactional if you configure your endpoint to be transactional (" + address + ")."); } var messageReadPropertyFilter = new MessagePropertyFilter { Body = true, TimeToBeReceived = true, Recoverable = true, Id = true, ResponseQueue = true, CorrelationId = true, Extension = true, AppSpecific = true }; queue.MessageReadPropertyFilter = messageReadPropertyFilter; if (PurgeOnStartup) { queue.Purge(); } }
public void Init(Address address, TransactionSettings transactionSettings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; workQueue = address.Queue; noAck = !transactionSettings.IsTransactional; if (receiveOptions.PurgeOnStartup) { //Purge(); } }
/// <summary> /// Initializes the <see cref="IDequeueMessages"/>. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="transactionSettings">The <see cref="TransactionSettings"/> to be used by <see cref="IDequeueMessages"/>.</param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage">Needs to be called by <see cref="IDequeueMessages"/> after the message has been processed regardless if the outcome was successful or not.</param> public void Init(Address address, TransactionSettings transactionSettings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; addressToPoll = address; settings = transactionSettings; transactionOptions = new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout }; MessageReceiver.Init(addressToPoll, settings.IsTransactional); }
public void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage) { this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; workQueue = address.Queue; noAck = !transactionSettings.IsTransactional; if (receiveOptions.PurgeOnStartup) { //Purge(); } }
public void Init() { LoadConfigurationSettings(); var transactionSettings = new TransactionSettings { MaxRetries = maximumNumberOfRetries }; Configure.Instance.Configurer.ConfigureComponent<TransportReceiver>(DependencyLifecycle.InstancePerCall) .ConfigureProperty(t => t.TransactionSettings, transactionSettings) .ConfigureProperty(t => t.MaximumConcurrencyLevel, numberOfWorkerThreadsInAppConfig) .ConfigureProperty(t => t.MaxThroughputPerSecond, maximumThroughput); }
public void Init(Address address, TransactionSettings settings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage, Func <ISession, IMessageConsumer> createConsumer) { endpointAddress = address; this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; this.createConsumer = createConsumer; transactionOptions = new TransactionOptions { IsolationLevel = settings.IsolationLevel, Timeout = settings.TransactionTimeout }; }
public ITransactionScope CreateNewTransactionScope(TransactionSettings transactionSettings, ISession session) { if (!transactionSettings.IsTransactional) { return new NoTransactionScope(); } if (transactionSettings.DontUseDistributedTransactions) { return new ActiveMqTransaction(sessionFactory, session); } return new DTCTransactionScope(session, new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout }, sessionFactory); }
public IReceiveStrategy Create(TransactionSettings settings, Func <TransportMessage, bool> tryProcessMessageCallback) { var errorQueue = new TableBasedQueue(errorQueueAddress, localConnectionParams.Schema); if (settings.IsTransactional) { if (settings.SuppressDistributedTransactions) { return(new NativeTransactionReceiveStrategy(localConnectionParams.ConnectionString, errorQueue, tryProcessMessageCallback, sqlConnectionFactory, connectionStore, settings)); } return(new AmbientTransactionReceiveStrategy(localConnectionParams.ConnectionString, errorQueue, tryProcessMessageCallback, sqlConnectionFactory, connectionStore, settings)); } return(new NoTransactionReceiveStrategy(localConnectionParams.ConnectionString, errorQueue, tryProcessMessageCallback, sqlConnectionFactory)); }
public async Task <SaveResult> SaveChangesAsync(JObject saveBundle, TransactionSettings transactionSettings = null) { if (SaveWorkState == null || SaveWorkState.WasUsed) { InitializeSaveState(saveBundle); } transactionSettings = transactionSettings ?? BreezeConfig.Instance.GetTransactionSettings(); try { if (transactionSettings.TransactionType == TransactionType.TransactionScope) { var txOptions = transactionSettings.ToTransactionOptions(); using (var txScope = new TransactionScope(TransactionScopeOption.Required, txOptions)) { await OpenAndSaveAsync(SaveWorkState); txScope.Complete(); } } else if (transactionSettings.TransactionType == TransactionType.DbTransaction) { this.OpenDbConnection(); using (IDbTransaction tran = BeginTransaction(transactionSettings.IsolationLevelAs)) { try { await OpenAndSaveAsync(SaveWorkState); await session.Transaction.CommitAsync(); } catch { session.Transaction.Rollback(); throw; } } } else { await OpenAndSaveAsync(SaveWorkState); } } catch (EntityErrorsException e) { SaveWorkState.EntityErrors = e.EntityErrors; throw; } catch (Exception e2) { if (!HandleSaveException(e2, SaveWorkState)) { throw; } } finally { CloseDbConnection(); } return(SaveWorkState.ToSaveResult()); }
public void Init() { LoadConfigurationSettings(); var transactionSettings = new TransactionSettings { MaxRetries = maximumNumberOfRetries }; Configure.Instance.Configurer.ConfigureComponent <TransportReceiver>(DependencyLifecycle.InstancePerCall) .ConfigureProperty(t => t.TransactionSettings, transactionSettings) .ConfigureProperty(t => t.MaximumConcurrencyLevel, numberOfWorkerThreadsInAppConfig) .ConfigureProperty(t => t.MaxThroughputPerSecond, maximumThroughput); }
public void Init(Address address, TransactionSettings transactionSettings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { var getQueueUrlRequest = new GetQueueUrlRequest(address.ToSqsQueueName(ConnectionConfiguration)); GetQueueUrlResponse getQueueUrlResponse; try { getQueueUrlResponse = SqsClient.GetQueueUrl(getQueueUrlRequest); } catch (Exception ex) { Logger.Error("Exception thrown from GetQueueUrl.", ex); throw; } _queueUrl = getQueueUrlResponse.QueueUrl; if (_purgeOnStartup) { // SQS only allows purging a queue once every 60 seconds or so. // If you try to purge a queue twice in relatively quick succession, // PurgeQueueInProgressException will be thrown. // This will happen if you are trying to start an endpoint twice or more // in that time. try { SqsClient.PurgeQueue(_queueUrl); } catch (PurgeQueueInProgressException ex) { Logger.Warn("Multiple queue purges within 60 seconds are not permitted by SQS.", ex); } catch (Exception ex) { Logger.Error("Exception thrown from PurgeQueue.", ex); throw; } } _tryProcessMessage = tryProcessMessage; _endProcessMessage = endProcessMessage; if (transactionSettings != null) { _isTransactional = transactionSettings.IsTransactional; } else { _isTransactional = true; } }
public void Init(Address address, TransactionSettings settings, Func <TransportMessage, bool> tryProcessMessage, Action <TransportMessage, Exception> endProcessMessage) { isTheMainTransport = address == Address.Local; endpointAddress = new WebSphereMqAddress(address); if (address == Address.Local) { subscriptionsManager.Init(settings, tryProcessMessage, endProcessMessage); } messageReceiver.Init(address, settings, tryProcessMessage, endProcessMessage, session => session.CreateConsumer(session.CreateQueue(endpointAddress.QueueName))); }
private void Initialize(TransactionConstructParams param, ITransactionServiceFactory serviceFactory) { _settings = new TransactionSettings(this, param); _orders = new BusinessRecordList <Order>("Orders", this, DEFAULT_ITEMS_CAPACITY); _autoFillService = new Lazy <AutoFillServiceBase>(() => serviceFactory.CreateAutoFillService()); _ifDoneService = new Lazy <IfDoneService>(() => new IfDoneService(this, _settings)); _executeService = new Lazy <TransactionExecuteService>(() => serviceFactory.CreateExecuteService(this, _settings)); _cancelService = new Lazy <BLL.TransactionBusiness.CancelService>(() => new BLL.TransactionBusiness.CancelService(this, _settings)); _precheckVerifier = new Lazy <PreCheckVerifierBase>(() => serviceFactory.CreatePreCheckVerifier(this)); _preCheckService = new Lazy <TransactionPreCheckService>(() => serviceFactory.CreatePreCheckService(this)); _fillService = new Lazy <FillServiceBase>(() => serviceFactory.CreateFillService(this, _settings)); _executeNecessaryCheckService = new Lazy <TransactionExecuteNecessaryCheckServiceBase>(() => serviceFactory.CreateExecuteNecessaryCheckService()); _instrumentId = _settings.InstrumentId; _settingInstrument = Setting.Default.GetInstrument(_instrumentId); }
public TransactionScope CreateTransactionScopeForAsyncMessage(TransactionSettings transactionSettings) { if (!transactionSettings.IsTransactional) { return null; } if (transactionSettings.DontUseDistributedTransactions) { return null; } return new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout }); }
public ITransactionScope CreateNewTransactionScope(TransactionSettings transactionSettings, ISession session) { if (!transactionSettings.IsTransactional) { return(new NoTransactionScope()); } if (transactionSettings.DontUseDistributedTransactions) { return(new ActiveMqTransaction(sessionFactory, session)); } return(new DTCTransactionScope(session, new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout }, sessionFactory)); }
public void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage) { var getQueueUrlRequest = new GetQueueUrlRequest(address.ToSqsQueueName(ConnectionConfiguration)); GetQueueUrlResponse getQueueUrlResponse; try { getQueueUrlResponse = SqsClient.GetQueueUrl(getQueueUrlRequest); } catch (Exception ex) { Logger.Error("Exception thrown from GetQueueUrl.", ex); throw; } _queueUrl = getQueueUrlResponse.QueueUrl; if (_purgeOnStartup) { // SQS only allows purging a queue once every 60 seconds or so. // If you try to purge a queue twice in relatively quick succession, // PurgeQueueInProgressException will be thrown. // This will happen if you are trying to start an endpoint twice or more // in that time. try { SqsClient.PurgeQueue(_queueUrl); } catch (PurgeQueueInProgressException ex) { Logger.Warn("Multiple queue purges within 60 seconds are not permitted by SQS.", ex); } catch (Exception ex) { Logger.Error("Exception thrown from PurgeQueue.", ex); throw; } } _tryProcessMessage = tryProcessMessage; _endProcessMessage = endProcessMessage; if (transactionSettings != null) _isTransactional = transactionSettings.IsTransactional; else _isTransactional = true; }
/// <summary> /// Initializes the <see cref="IDequeueMessages" />. /// </summary> /// <param name="primaryAddress">The address to listen on.</param> /// <param name="transactionSettings"> /// The <see cref="TransactionSettings" /> to be used by <see cref="IDequeueMessages" />. /// </param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage"> /// Needs to be called by <see cref="IDequeueMessages" /> after the message has been processed regardless if the /// outcome was successful or not. /// </param> public void Init(Address primaryAddress, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage) { queuePurger.Purge(primaryAddress); secondaryReceiveSettings = secondaryReceiveConfiguration.GetSettings(primaryAddress.Queue); var receiveStrategy = receiveStrategyFactory.Create(transactionSettings, tryProcessMessage); primaryReceiver = new AdaptivePollingReceiver(receiveStrategy, new TableBasedQueue(primaryAddress, locaConnectionParams.Schema), endProcessMessage, circuitBreaker, transportNotifications); if (secondaryReceiveSettings.IsEnabled) { var secondaryQueue = new TableBasedQueue(SecondaryReceiveSettings.ReceiveQueue.GetTableName(), locaConnectionParams.Schema); secondaryReceiver = new AdaptivePollingReceiver(receiveStrategy, secondaryQueue, endProcessMessage, circuitBreaker, transportNotifications); } else { secondaryReceiver = new NullExecutor(); } }
public void Init() { LoadConfigurationSettings(); if (LicenseManager.CurrentLicense.MaxThroughputPerSecond > 0) { if (maximumThroughput == 0 || LicenseManager.CurrentLicense.MaxThroughputPerSecond < maximumThroughput) maximumThroughput = LicenseManager.CurrentLicense.MaxThroughputPerSecond; } var transactionSettings = new TransactionSettings { MaxRetries = maximumNumberOfRetries }; Configure.Instance.Configurer.ConfigureComponent<TransportReceiver>(DependencyLifecycle.InstancePerCall) .ConfigureProperty(t => t.TransactionSettings, transactionSettings) .ConfigureProperty(t => t.MaximumConcurrencyLevel, GetAllowedNumberOfThreads(numberOfWorkerThreadsInAppConfig)) .ConfigureProperty(t => t.MaxThroughputPerSecond, maximumThroughput); }
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>() }, DependencyLifecycle.InstancePerCall); }
/// <summary> /// Initializes the <see cref="IDequeueMessages" />. /// </summary> /// <param name="address">The address to listen on.</param> /// <param name="transactionSettings"> /// The <see cref="TransactionSettings" /> to be used by <see cref="IDequeueMessages" />. /// </param> /// <param name="tryProcessMessage">Called when a message has been dequeued and is ready for processing.</param> /// <param name="endProcessMessage"> /// Needs to be called by <see cref="IDequeueMessages" /> after the message has been processed regardless if the outcome was successful or not. /// </param> public void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage) { this.tryProcessMessage = tryProcessMessage; this.endProcessMessage = endProcessMessage; settings = transactionSettings; transactionOptions = new TransactionOptions { IsolationLevel = transactionSettings.IsolationLevel, Timeout = transactionSettings.TransactionTimeout }; tableName = address.Queue; sql = string.Format(SqlReceive, tableName); if (PurgeOnStartup) { PurgeTable(); } }
private void StartTestee(TransactionSettings transactionSettings) { session = SetupCreateSession(); testee.Start(transactionSettings); }
public void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage) { }
public virtual void Start(TransactionSettings transactionSettings) { this.transactionSettings = transactionSettings; session = sessionFactory.GetSession(); }