コード例 #1
0
        /// <summary>
        /// Stores a subscription for the given message type and the given subscriber endpoint in the underlying SQL table.
        /// </summary>
        public void Store(Type eventType, string subscriberInputQueue)
        {
            using (var connection = factory.OpenConnection())
                using (var command = connection.CreateCommand())
                {
                    const string Sql = @"insert into ""{0}"" (""message_type"", ""endpoint"") values (@message_type, @endpoint)";

                    command.CommandText = string.Format(Sql, subscriptionsTableName);

                    command.AddParameter("message_type", eventType.FullName);
                    command.AddParameter("endpoint", subscriberInputQueue);

                    try
                    {
                        command.ExecuteNonQuery();
                    }
                    catch (DbException ex)
                    {
                        if (!AdoNetExceptionManager.IsDuplicatedKeyException(ex))
                        {
                            throw;
                        }
                    }
                }
        }
コード例 #2
0
		public AdoNetUnitOfWork(AdoNetConnectionFactory factory, IMessageContext context)
		{
			if (factory == null) throw new ArgumentNullException(nameof(factory));

			_factory = factory;
			_autodispose = context == null;
			__connection = new Lazy<Tuple<IDbConnection, IDbTransaction>>(() => {
				var connection = factory.OpenConnection();
				var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted); //< We may require 'Serializable' as our default.
				_log.Debug("Created new connection {0} and transaction {1}", connection.GetHashCode(), transaction.GetHashCode());
				return Tuple.Create(connection, transaction);
			});

			_log.Debug("Created new instance for context: {0}", context?.GetHashCode());
		}
コード例 #3
0
        public AdoNetUnitOfWork(AdoNetConnectionFactory factory, IMessageContext context)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            _factory     = factory;
            _autodispose = context == null;
            __connection = new Lazy <Tuple <IDbConnection, IDbTransaction> >(() => {
                var connection  = factory.OpenConnection();
                var transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted);                 //< We may require 'Serializable' as our default.
                _log.Debug("Created new connection {0} and transaction {1}", connection.GetHashCode(), transaction.GetHashCode());
                return(Tuple.Create(connection, transaction));
            });

            _log.Debug("Created new instance for context: {0}", context?.GetHashCode());
        }