/// <summary>
 ///     Return an NHibernate persistence configurerTells the bootstrapper to use a FluentNHibernate provider as a job
 ///     storage,
 ///     that can be accessed using the given connection string or
 ///     its name.
 /// </summary>
 /// <param name="nameOrConnectionString">Connection string or its name</param>
 /// <param name="providerType">Provider type from enumeration</param>
 /// <param name="options">Advanced options</param>
 public static IPersistenceConfigurer GetPersistenceConfigurer(ProviderTypeEnum providerType,
                                                               string nameOrConnectionString,
                                                               FluentNHibernateStorageOptions options = null)
 {
     return(FluentNHibernatePersistenceBuilder.GetPersistenceConfigurer(providerType,
                                                                        nameOrConnectionString, options));
 }
示例#2
0
        public FluentNHibernateJobStorage(SessionFactoryInfo info)
        {
            ProviderType    = info.ProviderType;
            _sessionFactory = info.SessionFactory;

            var tmp = info.Options as FluentNHibernateStorageOptions;

            Options = tmp ?? new FluentNHibernateStorageOptions();

            InitializeQueueProviders();
            _expirationManager     = new ExpirationManager(this, Options.JobExpirationCheckInterval);
            _countersAggregator    = new CountersAggregator(this, Options.CountersAggregateInterval);
            _serverTimeSyncManager = new ServerTimeSyncManager(this, TimeSpan.FromMinutes(5));


            //escalate session factory issues early
            try
            {
                EnsureDualHasOneRow();
                RefreshUtcOffset();
            }
            catch (FluentConfigurationException ex)
            {
                throw ex.InnerException ?? ex;
            }
        }
示例#3
0
 public static void WrapForDeadlock(Action safeAction, FluentNHibernateStorageOptions options)
 {
     WrapForDeadlock(() =>
     {
         safeAction();
         return(true);
     }, options);
 }
示例#4
0
        /// <summary>
        ///     Tells the bootstrapper to use FluentNHibernate provider as a job storage,
        ///     that can be accessed using the given connection string or
        ///     its name.
        /// </summary>
        /// <param name="configuration">Configuration</param>
        /// <param name="nameOrConnectionString">Connection string or its name</param>
        /// <param name="providerType">Provider type from enumeration</param>
        /// <param name="options">Advanced options</param>
        public static FluentNHibernateJobStorage UseFluentNHibernateJobStorage(
            this IGlobalConfiguration configuration,
            string nameOrConnectionString, ProviderTypeEnum providerType, FluentNHibernateStorageOptions options = null)
        {
            var storage = FluentNHibernateStorageFactory.For(providerType, nameOrConnectionString, options);

            configuration.UseStorage(storage);
            return(storage);
        }
        public FluentNHibernateDistributedLock(FluentNHibernateJobStorage storage, string resource, TimeSpan timeout,
                                               CancellationToken?cancellationToken = null)
        {
            Logger.DebugFormat("{2} resource={0}, timeout={1}", resource, timeout, GetType().Name);

            _resource          = resource;
            _timeout           = timeout;
            _cancellationToken = cancellationToken ?? new CancellationToken();
            _storage           = storage;
            _options           = storage.Options;
        }
示例#6
0
        public static T WrapForDeadlock <T>(Func <T> safeAction, FluentNHibernateStorageOptions options)
        {
            while (true)
            {
                try
                {
                    return(safeAction());
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("deadlock", StringComparison.InvariantCultureIgnoreCase) < 0)
                    {
                        throw;
                    }

                    Thread.Sleep(options.DeadlockRetryInterval);
                }
            }
        }
示例#7
0
 public FluentNHibernateJobStorage(IPersistenceConfigurer persistenceConfigurer,
                                   FluentNHibernateStorageOptions options = null) : this(SessionFactoryBuilder.GetFromAssemblyOf <_CounterMap>(
                                                                                             persistenceConfigurer, options))
 {
 }
示例#8
0
 public FluentNHibernateJobStorage(ProviderTypeEnum providerType, string nameOrConnectionString,
                                   FluentNHibernateStorageOptions options = null) : this(
         SessionFactoryBuilder.GetFromAssemblyOf <_CounterMap>(providerType, nameOrConnectionString, options))
 {
 }
 /// <summary>
 ///     Factory method.  Return a job storage provider based on the given provider type, connection string, and options
 /// </summary>
 /// <param name="nameOrConnectionString">Connection string or its name</param>
 /// <param name="providerType">Provider type from enumeration</param>
 /// <param name="options">Advanced options</param>
 public static FluentNHibernateJobStorage For(ProviderTypeEnum providerType, string nameOrConnectionString,
                                              FluentNHibernateStorageOptions options = null)
 {
     return(new FluentNHibernateJobStorage(providerType, nameOrConnectionString, options));
 }