示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FindExpiredRecordsToDeleteQueryPrepareHandler" /> class.
 /// </summary>
 /// <param name="commandCache">The command cache.</param>
 /// <param name="timeFactory">The time factory.</param>
 public FindExpiredRecordsToDeleteQueryPrepareHandler(CommandStringCache commandCache,
                                                      IGetTimeFactory timeFactory)
 {
     Guard.NotNull(() => commandCache, commandCache);
     _commandCache = commandCache;
     _getTime      = timeFactory.Create();
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SendMessageCommandHandler" /> class.
        /// </summary>
        /// <param name="tableNameHelper">The table name helper.</param>
        /// <param name="serializer">The serializer.</param>
        /// <param name="optionsFactory">The options factory.</param>
        /// <param name="headers">The headers.</param>
        /// <param name="commandCache">The command cache.</param>
        /// <param name="configurationSend">The configuration send.</param>
        /// <param name="sendJobStatus">The send job status.</param>
        /// <param name="jobExistsHandler">The job exists handler.</param>
        /// <param name="jobSchedulerMetaData">The job scheduler meta data.</param>
        /// <param name="getTimeFactory">The get time factory.</param>
        public SendMessageCommandHandlerAsync(ITableNameHelper tableNameHelper,
                                              ICompositeSerialization serializer,
                                              IPostgreSqlMessageQueueTransportOptionsFactory optionsFactory,
                                              IHeaders headers,
                                              PostgreSqlCommandStringCache commandCache,
                                              TransportConfigurationSend configurationSend,
                                              ICommandHandler <SetJobLastKnownEventCommand <NpgsqlConnection, NpgsqlTransaction> > sendJobStatus, IQueryHandler <DoesJobExistQuery <NpgsqlConnection, NpgsqlTransaction>, QueueStatuses> jobExistsHandler,
                                              IJobSchedulerMetaData jobSchedulerMetaData,
                                              IGetTimeFactory getTimeFactory)
        {
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => serializer, serializer);
            Guard.NotNull(() => optionsFactory, optionsFactory);
            Guard.NotNull(() => headers, headers);
            Guard.NotNull(() => commandCache, commandCache);
            Guard.NotNull(() => configurationSend, configurationSend);
            Guard.NotNull(() => sendJobStatus, sendJobStatus);
            Guard.NotNull(() => jobExistsHandler, jobExistsHandler);
            Guard.NotNull(() => jobSchedulerMetaData, jobSchedulerMetaData);
            Guard.NotNull(() => getTimeFactory, getTimeFactory);

            _tableNameHelper      = tableNameHelper;
            _serializer           = serializer;
            _options              = new Lazy <PostgreSqlMessageQueueTransportOptions>(optionsFactory.Create);
            _headers              = headers;
            _commandCache         = commandCache;
            _configurationSend    = configurationSend;
            _sendJobStatus        = sendJobStatus;
            _jobExistsHandler     = jobExistsHandler;
            _jobSchedulerMetaData = jobSchedulerMetaData;
            _getTime              = getTimeFactory.Create();
        }
        /// <inheritdoc />
        public ResetHeartbeatLua(IRedisConnection connection, RedisNames redisNames, IGetTimeFactory getTime, ICompositeSerialization serialization)
            : base(connection, redisNames)
        {
            _getTime       = getTime.Create();
            _serialization = serialization;
            Script         = @"local returnData = {}
                        local uuids = redis.call('zrangebyscore', @workingkey, 0, @heartbeattime, 'LIMIT', 0, @limit)
                        if #uuids == 0 then
	                        return nil
                        end
                        local index = 1
                        for k, v in pairs(uuids) do                             
	                        redis.call('zrem',  @workingkey, v)
                            local routeName = redis.call('hget', @RouteIDKey, v) 
                            if(routeName) then
                                local routePending = @pendingkey .. '_}' .. routeName
                                redis.call('rpush', routePending, v) 
                            else
	                            redis.call('rpush', @pendingkey, v) 
                            end
                            redis.call('hset', @StatusKey, v, '0') 
                            returnData[index] = {v, redis.call('hget', @headerskey, v)}
                            index = index + 1
                        end
                        redis.call('publish', @channel, '') 
                        return returnData";
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ReceiveMessageQueryHandler" /> class.
        /// </summary>
        /// <param name="optionsFactory">The options factory.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        /// <param name="receivedMessageFactory">The received message factory.</param>
        /// <param name="commandCache">The command cache.</param>
        /// <param name="messageFactory">The message factory.</param>
        /// <param name="headers">The headers.</param>
        /// <param name="serialization">The serialization.</param>
        /// <param name="getTimeFactory">The get time factory.</param>
        public ReceiveMessageQueryHandler(IPostgreSqlMessageQueueTransportOptionsFactory optionsFactory,
                                          ITableNameHelper tableNameHelper,
                                          IReceivedMessageFactory receivedMessageFactory,
                                          PostgreSqlCommandStringCache commandCache,
                                          IMessageFactory messageFactory,
                                          IHeaders headers,
                                          ICompositeSerialization serialization,
                                          IGetTimeFactory getTimeFactory)
        {
            Guard.NotNull(() => optionsFactory, optionsFactory);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => receivedMessageFactory, receivedMessageFactory);
            Guard.NotNull(() => commandCache, commandCache);
            Guard.NotNull(() => messageFactory, messageFactory);
            Guard.NotNull(() => serialization, serialization);
            Guard.NotNull(() => headers, headers);
            Guard.NotNull(() => getTimeFactory, getTimeFactory);

            _options                = new Lazy <PostgreSqlMessageQueueTransportOptions>(optionsFactory.Create);
            _tableNameHelper        = tableNameHelper;
            _receivedMessageFactory = receivedMessageFactory;
            _commandCache           = commandCache;
            _messageFactory         = messageFactory;
            _headers                = headers;
            _serialization          = serialization;
            _getTime                = getTimeFactory.Create();
        }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JobScheduler"/> class.
 /// </summary>
 /// <param name="jobQueue">The job queue.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 /// <param name="log">The log factory.</param>
 public JobScheduler(IJobQueue jobQueue,
                     IGetTimeFactory getTimeFactory,
                     ILogger log)
 {
     _jobQueue = jobQueue;
     _getTime  = getTimeFactory;
     _log      = log;
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueStatusProviderBase" /> class.
 /// </summary>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 protected QueueStatusProviderBase(IConnectionInformation connectionInformation,
                                   IGetTimeFactory getTimeFactory)
 {
     TimeFactory           = getTimeFactory;
     ConnectionInformation = connectionInformation;
     Name   = connectionInformation.QueueName;
     Server = connectionInformation.Server;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SendHeartBeatCommandPrepareHandler"/> class.
 /// </summary>
 /// <param name="commandCache">The command cache.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 public SendHeartBeatCommandPrepareHandler(CommandStringCache commandCache,
                                           IGetTimeFactory getTimeFactory)
 {
     Guard.NotNull(() => commandCache, commandCache);
     Guard.NotNull(() => getTimeFactory, getTimeFactory);
     _commandCache = commandCache;
     _getTime      = getTimeFactory.Create();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MoveRecordToErrorQueueCommandPrepareHandler" /> class.
 /// </summary>
 /// <param name="buildSql">The build SQL.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 public MoveRecordToErrorQueueCommandPrepareHandler(IBuildMoveToErrorQueueSql buildSql,
                                                    IGetTimeFactory getTimeFactory)
 {
     Guard.NotNull(() => buildSql, buildSql);
     Guard.NotNull(() => getTimeFactory, getTimeFactory);
     _buildSql = buildSql;
     _getTime  = getTimeFactory.Create();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueStatusProviderBase" /> class.
 /// </summary>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 protected QueueStatusProviderBase(IConnectionInformation connectionInformation,
     IGetTimeFactory getTimeFactory)
 {
     TimeFactory = getTimeFactory;
     ConnectionInformation = connectionInformation;
     Name = connectionInformation.QueueName;
     Server = connectionInformation.Server;
 }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JobScheduler"/> class.
 /// </summary>
 /// <param name="jobQueue">The job queue.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 /// <param name="logFactory">The log factory.</param>
 public JobScheduler(IJobQueue jobQueue,
                     IGetTimeFactory getTimeFactory,
                     ILogFactory logFactory)
 {
     _jobQueue   = jobQueue;
     _getTime    = getTimeFactory;
     _logFactory = logFactory;
 }
        private void WaitForRollover(IGetTimeFactory timeFactory)
        {
            var getTime = timeFactory.Create();

            while (getTime.GetCurrentUtcDate().Second != 55)
            {
                Thread.Sleep(100);
            }
        }
示例#12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HeartBeatScheduler"/> class.
        /// </summary>
        public HeartBeatScheduler(IHeartBeatThreadPoolConfiguration configuration,
                                  IGetTimeFactory timeFactory)
        {
            Guard.NotNull(() => configuration, configuration);
            Guard.NotNull(() => timeFactory, timeFactory);

            _configuration = configuration;
            _timeFactory   = timeFactory;
        }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SendToJobQueue" /> class.
 /// </summary>
 /// <param name="queue">The queue.</param>
 /// <param name="dataStorage">The data storage.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 /// <param name="createJobMetaData">The create job meta data.</param>
 public SendToJobQueue(IProducerMethodQueue queue,
                       IDataStorage dataStorage,
                       IGetTimeFactory getTimeFactory,
                       CreateJobMetaData createJobMetaData
                       ) : base(queue, getTimeFactory)
 {
     _dataStorage       = dataStorage;
     _createJobMetaData = createJobMetaData;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SqliteSendToJobQueue" /> class.
 /// </summary>
 /// <param name="queue">The queue.</param>
 /// <param name="doesJobExist">Query for determining if a job already exists</param>
 /// <param name="deleteMessageCommand">The delete message command.</param>
 /// <param name="getJobId">The get job identifier.</param>
 /// <param name="createJobMetaData">The create job meta data.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 public SqliteSendToJobQueue(IProducerMethodQueue queue, IQueryHandler<DoesJobExistQuery, QueueStatuses> doesJobExist,
     ICommandHandlerWithOutput<DeleteMessageCommand, long> deleteMessageCommand,
     IQueryHandler<GetJobIdQuery, long> getJobId, CreateJobMetaData createJobMetaData,
     IGetTimeFactory getTimeFactory): base(queue, getTimeFactory)
 {
     _doesJobExist = doesJobExist;
     _deleteMessageCommand = deleteMessageCommand;
     _getJobId = getJobId;
     _createJobMetaData = createJobMetaData;
 }
示例#15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqliteSendToJobQueue" /> class.
 /// </summary>
 /// <param name="queue">The queue.</param>
 /// <param name="doesJobExist">Query for determining if a job already exists</param>
 /// <param name="deleteMessageCommand">The delete message command.</param>
 /// <param name="getJobId">The get job identifier.</param>
 /// <param name="createJobMetaData">The create job meta data.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 public SqliteSendToJobQueue(IProducerMethodQueue queue, IQueryHandler <DoesJobExistQuery <IDbConnection, IDbTransaction>, QueueStatuses> doesJobExist,
                             ICommandHandlerWithOutput <DeleteMessageCommand, long> deleteMessageCommand,
                             IQueryHandler <GetJobIdQuery, long> getJobId, CreateJobMetaData createJobMetaData,
                             IGetTimeFactory getTimeFactory) : base(queue, getTimeFactory)
 {
     _doesJobExist         = doesJobExist;
     _deleteMessageCommand = deleteMessageCommand;
     _getJobId             = getJobId;
     _createJobMetaData    = createJobMetaData;
 }
示例#16
0
 /// <inheritdoc />
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueStatusProvider" /> class.
 /// </summary>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 /// <param name="optionsFactory">The options factory.</param>
 /// <param name="serializer">The serializer.</param>
 /// <param name="queries">The queries.</param>
 public QueueStatusProvider(IConnectionInformation connectionInformation,
                            IGetTimeFactory getTimeFactory,
                            ITransportOptionsFactory optionsFactory,
                            IInternalSerializer serializer,
                            QueueStatusQueries queries) : base(connectionInformation, getTimeFactory)
 {
     _serializer = serializer;
     _queries    = queries;
     _options    = new Lazy <ITransportOptions>(optionsFactory.Create);
 }
示例#17
0
 /// <summary>Initializes a new instance of the <see cref="SqliteSendToJobQueue"/> class.</summary>
 /// <param name="queue">The queue.</param>
 /// <param name="doesJobExist">Query for determining if a job already exists</param>
 /// <param name="removeMessage">The remove message.</param>
 /// <param name="getJobId">The get job identifier.</param>
 /// <param name="createJobMetaData">The create job meta data.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 public SqliteSendToJobQueue(IProducerMethodQueue queue, IQueryHandler <DoesJobExistQuery <IDbConnection, IDbTransaction>, QueueStatuses> doesJobExist,
                             IRemoveMessage removeMessage,
                             IQueryHandler <GetJobIdQuery, long> getJobId, CreateJobMetaData createJobMetaData,
                             IGetTimeFactory getTimeFactory) : base(queue, getTimeFactory)
 {
     _doesJobExist      = doesJobExist;
     _removeMessage     = removeMessage;
     _getJobId          = getJobId;
     _createJobMetaData = createJobMetaData;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSqlQueueStatusProvider" /> class.
 /// </summary>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 /// <param name="optionsFactory">The options factory.</param>
 /// <param name="serializer">The serializer.</param>
 /// <param name="queries">The queries.</param>
 public PostgreSqlQueueStatusProvider(IConnectionInformation connectionInformation,
     IGetTimeFactory getTimeFactory,
     IPostgreSqlMessageQueueTransportOptionsFactory optionsFactory,
     IInternalSerializer serializer, 
     PostgreSqlMessageQueueStatusQueries queries) : base(connectionInformation, getTimeFactory)
 {
     _serializer = serializer;
     _queries = queries;
     _options = new Lazy<PostgreSqlMessageQueueTransportOptions>(optionsFactory.Create);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FindErrorRecordsToDeleteQueryPrepareHandler"/> class.
 /// </summary>
 /// <param name="commandCache">The command cache.</param>
 /// <param name="timeFactory">The time factory.</param>
 /// <param name="configuration">The configuration.</param>
 public FindErrorRecordsToDeleteQueryPrepareHandler(CommandStringCache commandCache,
                                                    IGetTimeFactory timeFactory,
                                                    IMessageErrorConfiguration configuration)
 {
     Guard.NotNull(() => commandCache, commandCache);
     Guard.NotNull(() => timeFactory, timeFactory);
     _commandCache  = commandCache;
     _configuration = configuration;
     _getTime       = timeFactory.Create();
 }
示例#20
0
 /// <summary>Initializes a new instance of the <see cref="RedisSendJobToQueue"/> class.</summary>
 /// <param name="queue">The queue.</param>
 /// <param name="doesJobExist">Query for determining if a job already exists</param>
 /// <param name="removeMessage">removes a message</param>
 /// <param name="getJobId">The get job identifier.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 /// <param name="jobSchedulerMetaData">The job scheduler meta data.</param>
 public RedisSendJobToQueue(IProducerMethodQueue queue, IQueryHandler <DoesJobExistQuery, QueueStatuses> doesJobExist,
                            IRemoveMessage removeMessage,
                            IQueryHandler <GetJobIdQuery, string> getJobId,
                            IGetTimeFactory getTimeFactory,
                            IJobSchedulerMetaData jobSchedulerMetaData) : base(queue, getTimeFactory)
 {
     _doesJobExist         = doesJobExist;
     _removeMessage        = removeMessage;
     _getJobId             = getJobId;
     _jobSchedulerMetaData = jobSchedulerMetaData;
 }
示例#21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RedisSendJobToQueue" /> class.
 /// </summary>
 /// <param name="queue">The queue.</param>
 /// <param name="doesJobExist">Query for determining if a job already exists</param>
 /// <param name="deleteMessageCommand">The delete message command.</param>
 /// <param name="getJobId">The get job identifier.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 /// <param name="jobSchedulerMetaData">The job scheduler meta data.</param>
 public RedisSendJobToQueue(IProducerMethodQueue queue, IQueryHandler <DoesJobExistQuery, QueueStatuses> doesJobExist,
                            ICommandHandlerWithOutput <DeleteMessageCommand, bool> deleteMessageCommand,
                            IQueryHandler <GetJobIdQuery, string> getJobId,
                            IGetTimeFactory getTimeFactory,
                            IJobSchedulerMetaData jobSchedulerMetaData) : base(queue, getTimeFactory)
 {
     _doesJobExist         = doesJobExist;
     _deleteMessageCommand = deleteMessageCommand;
     _getJobId             = getJobId;
     _jobSchedulerMetaData = jobSchedulerMetaData;
 }
 /// <summary>Initializes a new instance of the <see cref="PostgreSqlSendJobToQueue"/> class.</summary>
 /// <param name="queue">The queue.</param>
 /// <param name="doesJobExist">Query for determining if a job already exists</param>
 /// <param name="getJobId">The get job identifier.</param>
 /// <param name="createJobMetaData">The create job meta data.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 /// <param name="removeMessage"></param>
 /// <inheritdoc />
 public PostgreSqlSendJobToQueue(IProducerMethodQueue queue, IQueryHandler <DoesJobExistQuery <NpgsqlConnection, NpgsqlTransaction>, QueueStatuses> doesJobExist,
                                 IQueryHandler <GetJobIdQuery, long> getJobId,
                                 CreateJobMetaData createJobMetaData,
                                 IGetTimeFactory getTimeFactory,
                                 IRemoveMessage removeMessage) : base(queue, getTimeFactory)
 {
     _doesJobExist      = doesJobExist;
     _getJobId          = getJobId;
     _createJobMetaData = createJobMetaData;
     _removeMessage     = removeMessage;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RedisSendJobToQueue" /> class.
 /// </summary>
 /// <param name="queue">The queue.</param>
 /// <param name="doesJobExist">Query for determining if a job already exists</param>
 /// <param name="deleteMessageCommand">The delete message command.</param>
 /// <param name="getJobId">The get job identifier.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 /// <param name="jobSchedulerMetaData">The job scheduler meta data.</param>
 public RedisSendJobToQueue(IProducerMethodQueue queue, IQueryHandler<DoesJobExistQuery, QueueStatuses> doesJobExist,
     ICommandHandlerWithOutput<DeleteMessageCommand, bool> deleteMessageCommand,
     IQueryHandler<GetJobIdQuery, string> getJobId, 
     IGetTimeFactory getTimeFactory, 
     IJobSchedulerMetaData jobSchedulerMetaData): base(queue, getTimeFactory)
 {
     _doesJobExist = doesJobExist;
     _deleteMessageCommand = deleteMessageCommand;
     _getJobId = getJobId;
     _jobSchedulerMetaData = jobSchedulerMetaData;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FindRecordsToResetByHeartBeatQueryPrepareHandler" /> class.
 /// </summary>
 /// <param name="commandCache">The command cache.</param>
 /// <param name="configuration">The configuration.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 public FindRecordsToResetByHeartBeatQueryPrepareHandler(CommandStringCache commandCache,
                                                         QueueConsumerConfiguration configuration,
                                                         IGetTimeFactory getTimeFactory)
 {
     Guard.NotNull(() => commandCache, commandCache);
     Guard.NotNull(() => configuration, configuration);
     Guard.NotNull(() => getTimeFactory, getTimeFactory);
     _commandCache  = commandCache;
     _configuration = configuration;
     _getTime       = getTimeFactory.Create();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LiteDbSendJobToQueue"/> class.
 /// </summary>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="queue">The queue.</param>
 /// <param name="doesJobExist">The does job exist.</param>
 /// <param name="removeMessage">The remove message.</param>
 /// <param name="getJobId">The get job identifier.</param>
 /// <param name="createJobMetaData">The create job meta data.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 public LiteDbSendJobToQueue(LiteDbConnectionManager connectionInformation, IProducerMethodQueue queue, IQueryHandler <DoesJobExistQuery, QueueStatuses> doesJobExist,
                             IRemoveMessage removeMessage,
                             IQueryHandler <GetJobIdQuery <int>, int> getJobId, CreateJobMetaData createJobMetaData,
                             IGetTimeFactory getTimeFactory) : base(queue, getTimeFactory)
 {
     _doesJobExist          = doesJobExist;
     _removeMessage         = removeMessage;
     _getJobId              = getJobId;
     _createJobMetaData     = createJobMetaData;
     _connectionInformation = connectionInformation;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RollbackMessageCommandHandler" /> class.
 /// </summary>
 /// <param name="getUtcDateQuery">The get UTC date query.</param>
 /// <param name="options">The options.</param>
 /// <param name="tableNameHelper">The table name helper.</param>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="commandCache">The command cache.</param>
 public RollbackMessageCommandHandler(IGetTimeFactory getUtcDateQuery,
                                      IPostgreSqlMessageQueueTransportOptionsFactory options,
                                      TableNameHelper tableNameHelper,
                                      IConnectionInformation connectionInformation,
                                      PostgreSqlCommandStringCache commandCache)
 {
     _getUtcDateQuery       = getUtcDateQuery;
     _options               = new Lazy <PostgreSqlMessageQueueTransportOptions>(options.Create);
     _tableNameHelper       = tableNameHelper;
     _connectionInformation = connectionInformation;
     _commandCache          = commandCache;
     _rollbackDictionary    = new ConcurrentDictionary <string, string>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReceiveMessagesDecorator" /> class.
 /// </summary>
 /// <param name="metrics">The metrics factory.</param>
 /// <param name="headers">The headers.</param>
 /// <param name="getTime">The get time.</param>
 /// <param name="handler">The handler.</param>
 /// <param name="connectionInformation">The connection information.</param>
 public ReceiveMessagesDecorator(IMetrics metrics,
     IHeaders headers,
     IGetTimeFactory getTime,
     IReceiveMessages handler,
     IConnectionInformation connectionInformation)
 {
     var name = handler.GetType().Name;
     _meter = metrics.Meter($"{connectionInformation.QueueName}.{name}.ReceiveMessageMeter", Units.Items);
     _waitTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.WaitForDeQueueMeter", Units.None);
     _handler = handler;
     _getTime = getTime;
     _headers = headers;
 }
示例#28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResetHeartBeat{T}"/> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="commandHandler">The command handler.</param>
        /// <param name="queryHandler">The query handler.</param>
        /// <param name="getTime">The get time.</param>
        public ResetHeartBeat(QueueConsumerConfiguration configuration,
                              ICommandHandlerWithOutput <ResetHeartBeatCommand <T>, long> commandHandler,
                              IQueryHandler <FindMessagesToResetByHeartBeatQuery <T>, IEnumerable <MessageToReset <T> > > queryHandler,
                              IGetTimeFactory getTime)
        {
            Guard.NotNull(() => configuration, configuration);
            Guard.NotNull(() => commandHandler, commandHandler);
            Guard.NotNull(() => queryHandler, queryHandler);

            _configuration  = configuration;
            _commandHandler = commandHandler;
            _queryHandler   = queryHandler;
            _getTime        = getTime.Create();
        }
示例#29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReceiveMessagesDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="headers">The headers.</param>
        /// <param name="getTime">The get time.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public ReceiveMessagesDecorator(IMetrics metrics,
                                        IHeaders headers,
                                        IGetTimeFactory getTime,
                                        IReceiveMessages handler,
                                        IConnectionInformation connectionInformation)
        {
            var name = "ReceiveMessages";

            _meter     = metrics.Meter($"{connectionInformation.QueueName}.{name}.ReceiveMessageMeter", Units.Items);
            _waitTimer = metrics.Timer($"{connectionInformation.QueueName}.{name}.WaitForDeQueueMeter", Units.None);
            _handler   = handler;
            _getTime   = getTime;
            _headers   = headers;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RollbackMessageCommandHandler" /> class.
 /// </summary>
 /// <param name="getUtcDateQuery">The get UTC date query.</param>
 /// <param name="options">The options.</param>
 /// <param name="tableNameHelper">The table name helper.</param>
 /// <param name="connectionInformation">The connection information.</param>
 /// <param name="commandCache">The command cache.</param>
 /// <param name="dbFactory">The database factory.</param>
 /// <param name="databaseExists">The database exists.</param>
 public RollbackMessageCommandHandler(IGetTimeFactory getUtcDateQuery,
                                      ISqLiteMessageQueueTransportOptionsFactory options,
                                      ITableNameHelper tableNameHelper,
                                      IConnectionInformation connectionInformation,
                                      IDbCommandStringCache commandCache,
                                      IDbFactory dbFactory,
                                      DatabaseExists databaseExists)
 {
     _getUtcDateQuery       = getUtcDateQuery;
     _options               = new Lazy <SqLiteMessageQueueTransportOptions>(options.Create);
     _tableNameHelper       = tableNameHelper;
     _connectionInformation = connectionInformation;
     _commandCache          = commandCache;
     _rollbackDictionary    = new ConcurrentDictionary <string, string>();
     _dbFactory             = dbFactory;
     _databaseExists        = databaseExists;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisQueueStatusProvider" /> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="getTimeFactory">The get time factory.</param>
        /// <param name="pendingQueryHandler">The pending query handler.</param>
        /// <param name="pendingDelayedQueryHandler">The pending delayed query handler.</param>
        /// <param name="workingCountQueryHandler">The working count query handler.</param>
        /// <param name="errorCountQueryHandler">The error count query handler.</param>
        public RedisQueueStatusProvider(IConnectionInformation connectionInformation,
            IGetTimeFactory getTimeFactory,
            IQueryHandler<GetPendingCountQuery, long> pendingQueryHandler,
            IQueryHandler<GetPendingDelayedCountQuery, long> pendingDelayedQueryHandler,
            IQueryHandler<GetWorkingCountQuery, long> workingCountQueryHandler,
            IQueryHandler<GetErrorCountQuery, long> errorCountQueryHandler) : base(connectionInformation, getTimeFactory)
        {
            Guard.NotNull(() => pendingQueryHandler, pendingQueryHandler);
            Guard.NotNull(() => pendingDelayedQueryHandler, pendingDelayedQueryHandler);
            Guard.NotNull(() => workingCountQueryHandler, workingCountQueryHandler);
            Guard.NotNull(() => errorCountQueryHandler, errorCountQueryHandler);

            _pendingQueryHandler = pendingQueryHandler;
            _pendingDelayedQueryHandler = pendingDelayedQueryHandler;
            _workingQueryHandler = workingCountQueryHandler;
            _errorQueryHandler = errorCountQueryHandler;
        }
示例#32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RedisQueueStatusProvider" /> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="getTimeFactory">The get time factory.</param>
        /// <param name="pendingQueryHandler">The pending query handler.</param>
        /// <param name="pendingDelayedQueryHandler">The pending delayed query handler.</param>
        /// <param name="workingCountQueryHandler">The working count query handler.</param>
        /// <param name="errorCountQueryHandler">The error count query handler.</param>
        public RedisQueueStatusProvider(IConnectionInformation connectionInformation,
                                        IGetTimeFactory getTimeFactory,
                                        IQueryHandler <GetPendingCountQuery, long> pendingQueryHandler,
                                        IQueryHandler <GetPendingDelayedCountQuery, long> pendingDelayedQueryHandler,
                                        IQueryHandler <GetWorkingCountQuery, long> workingCountQueryHandler,
                                        IQueryHandler <GetErrorCountQuery, long> errorCountQueryHandler) : base(connectionInformation, getTimeFactory)
        {
            Guard.NotNull(() => pendingQueryHandler, pendingQueryHandler);
            Guard.NotNull(() => pendingDelayedQueryHandler, pendingDelayedQueryHandler);
            Guard.NotNull(() => workingCountQueryHandler, workingCountQueryHandler);
            Guard.NotNull(() => errorCountQueryHandler, errorCountQueryHandler);

            _pendingQueryHandler        = pendingQueryHandler;
            _pendingDelayedQueryHandler = pendingDelayedQueryHandler;
            _workingQueryHandler        = workingCountQueryHandler;
            _errorQueryHandler          = errorCountQueryHandler;
        }
示例#33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RollbackMessageCommandHandler" /> class.
        /// </summary>
        /// <param name="getUtcDateQuery">The get UTC date query.</param>
        /// <param name="options">The options.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="databaseExists">The database exists.</param>
        public RollbackMessageCommandHandler(IGetTimeFactory getUtcDateQuery,
                                             ILiteDbMessageQueueTransportOptionsFactory options,
                                             TableNameHelper tableNameHelper,
                                             LiteDbConnectionManager connectionInformation,
                                             DatabaseExists databaseExists)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => getUtcDateQuery, getUtcDateQuery);
            Guard.NotNull(() => options, options);
            Guard.NotNull(() => databaseExists, databaseExists);

            _getUtcDateQuery       = getUtcDateQuery;
            _options               = new Lazy <LiteDbMessageQueueTransportOptions>(options.Create);
            _tableNameHelper       = tableNameHelper;
            _connectionInformation = connectionInformation;
            _databaseExists        = databaseExists;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SendMessageCommandHandler" /> class.
        /// </summary>
        /// <param name="tableNameHelper">The table name helper.</param>
        /// <param name="serializer">The serializer.</param>
        /// <param name="optionsFactory">The options factory.</param>
        /// <param name="headers">The headers.</param>
        /// <param name="commandCache">The command cache.</param>
        /// <param name="configurationSend">The configuration send.</param>
        /// <param name="getTimeFactory">The get time factory.</param>
        /// <param name="dbFactory">The database factory.</param>
        /// <param name="sendJobStatus">The send job status.</param>
        /// <param name="jobExistsHandler">The job exists handler.</param>
        /// <param name="jobSchedulerMetaData">The job scheduler meta data.</param>
        /// <param name="databaseExists">The database exists.</param>
        /// <param name="readerAsync">The reader asynchronous.</param>
        public SendMessageCommandHandlerAsync(TableNameHelper tableNameHelper,
                                              ICompositeSerialization serializer,
                                              ISqLiteMessageQueueTransportOptionsFactory optionsFactory,
                                              IHeaders headers,
                                              IDbCommandStringCache commandCache,
                                              TransportConfigurationSend configurationSend,
                                              IGetTimeFactory getTimeFactory,
                                              IDbFactory dbFactory,
                                              ICommandHandler <SetJobLastKnownEventCommand <IDbConnection, IDbTransaction> > sendJobStatus,
                                              IQueryHandler <DoesJobExistQuery <IDbConnection, IDbTransaction>, QueueStatuses> jobExistsHandler,
                                              IJobSchedulerMetaData jobSchedulerMetaData,
                                              DatabaseExists databaseExists,
                                              IReaderAsync readerAsync)
        {
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => serializer, serializer);
            Guard.NotNull(() => optionsFactory, optionsFactory);
            Guard.NotNull(() => headers, headers);
            Guard.NotNull(() => commandCache, commandCache);
            Guard.NotNull(() => configurationSend, configurationSend);
            Guard.NotNull(() => getTimeFactory, getTimeFactory);
            Guard.NotNull(() => sendJobStatus, sendJobStatus);
            Guard.NotNull(() => jobExistsHandler, jobExistsHandler);
            Guard.NotNull(() => jobSchedulerMetaData, jobSchedulerMetaData);
            Guard.NotNull(() => databaseExists, databaseExists);
            Guard.NotNull(() => readerAsync, readerAsync);

            _tableNameHelper      = tableNameHelper;
            _serializer           = serializer;
            _options              = new Lazy <SqLiteMessageQueueTransportOptions>(optionsFactory.Create);
            _headers              = headers;
            _commandCache         = commandCache;
            _configurationSend    = configurationSend;
            _getTime              = getTimeFactory.Create();
            _dbFactory            = dbFactory;
            _sendJobStatus        = sendJobStatus;
            _jobExistsHandler     = jobExistsHandler;
            _jobSchedulerMetaData = jobSchedulerMetaData;
            _databaseExists       = databaseExists;
            _readerAsync          = readerAsync;
        }
        public void RunEnqueueTestDynamic <TTransportInit, TJobQueueCreator>(string queueName,
                                                                             string connectionString,
                                                                             bool addInterceptors,
                                                                             Action <string, string, long, ICreationScope> verify,
                                                                             Action <string, string, ICreationScope> setErrorFlag,
                                                                             IGetTimeFactory timeFactory, ICreationScope scope,
                                                                             ILogProvider logProvider)
            where TTransportInit : ITransportInit, new()
            where TJobQueueCreator : class, IJobQueueCreation
        {
            _timeFactory = timeFactory;
            _logProvider = logProvider;
            using (var jobQueueCreation =
                       new JobQueueCreationContainer <TTransportInit>())
            {
                using (
                    var createQueue = jobQueueCreation.GetQueueCreation <TJobQueueCreator>(queueName,
                                                                                           connectionString)
                    )
                {
                    RunEnqueueTest <TTransportInit>(queueName, connectionString, addInterceptors, verify,
                                                    setErrorFlag,
                                                    (x, name) => x.AddUpdateJob <TTransportInit>(createQueue, name, queueName, connectionString,
                                                                                                 "min(*)",
                                                                                                 new LinqExpressionToRun(
                                                                                                     "(message, workerNotification) => Console.WriteLine(DateTime.Now.Ticks)")),

                                                    (x, name, time) =>
                                                    x.AddUpdateJob <TTransportInit>(createQueue, name, queueName, connectionString,
                                                                                    "min(*)",
                                                                                    new LinqExpressionToRun(
                                                                                        "(message, workerNotification) => Console.WriteLine(DateTime.Now.Ticks)"), null, null, true,
                                                                                    time), timeFactory, scope, logProvider
                                                    );
                }
            }
        }
        public void RunEnqueueTestCompiled <TTransportInit, TJobQueueCreator>(string queueName,
                                                                              string connectionString,
                                                                              bool addInterceptors,
                                                                              Action <string, string, long, ICreationScope> verify,
                                                                              Action <string, string, ICreationScope> setErrorFlag,
                                                                              IGetTimeFactory timeFactory, ICreationScope scope,
                                                                              ILogProvider logProvider)
            where TTransportInit : ITransportInit, new()
            where TJobQueueCreator : class, IJobQueueCreation
        {
            _timeFactory = timeFactory;
            _logProvider = logProvider;
            RunEnqueueTest <TTransportInit>(queueName, connectionString, addInterceptors, verify,
                                            setErrorFlag,
                                            (x, name) => x.AddUpdateJob <TTransportInit, TJobQueueCreator>(name, queueName, connectionString,
                                                                                                           "min(*)",
                                                                                                           (message, workerNotification) => Console.WriteLine(message.MessageId.Id.Value), null, config => { }),

                                            (x, name, time) => x.AddUpdateJob <TTransportInit, TJobQueueCreator>(name, queueName, connectionString,
                                                                                                                 "min(*)",
                                                                                                                 (message, workerNotification) => Console.WriteLine(message.MessageId.Id.Value), null, config => { }, true, time), timeFactory, scope, logProvider

                                            );
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetFirstMessageDeliveryTime"/> class.
 /// </summary>
 /// <param name="getTime">The get time.</param>
 public GetFirstMessageDeliveryTime(IGetTimeFactory getTime)
 {
     _getTime = getTime;
 }
 public BuildDequeueCommand(IGetTimeFactory getTimeFactory)
 {
     Guard.NotNull(() => getTimeFactory, getTimeFactory);
     _getTime = getTimeFactory.Create();
 }
示例#39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ASendJobToQueue" /> class.
 /// </summary>
 /// <param name="queue">The queue.</param>
 /// <param name="getTimeFactory">The get time factory.</param>
 protected ASendJobToQueue(IProducerMethodQueue queue, 
     IGetTimeFactory getTimeFactory)
 {
     Queue = queue;
     GetTimeFactory = getTimeFactory;
 }