/// <summary>
        /// Initializes a new instance of the <see cref="SendMessageCommandHandlerAsync"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <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="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="databaseExists">The database exists.</param>
        public SendMessageCommandHandlerAsync(
            LiteDbConnectionManager connectionInformation,
            TableNameHelper tableNameHelper,
            ICompositeSerialization serializer,
            ILiteDbMessageQueueTransportOptionsFactory optionsFactory,
            IHeaders headers,
            TransportConfigurationSend configurationSend,
            ICommandHandler <SetJobLastKnownEventCommand> sendJobStatus, IQueryHandler <DoesJobExistQuery, QueueStatuses> jobExistsHandler,
            IJobSchedulerMetaData jobSchedulerMetaData,
            DatabaseExists databaseExists)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => serializer, serializer);
            Guard.NotNull(() => optionsFactory, optionsFactory);
            Guard.NotNull(() => headers, headers);
            Guard.NotNull(() => configurationSend, configurationSend);
            Guard.NotNull(() => sendJobStatus, sendJobStatus);
            Guard.NotNull(() => jobExistsHandler, jobExistsHandler);
            Guard.NotNull(() => jobSchedulerMetaData, jobSchedulerMetaData);
            Guard.NotNull(() => databaseExists, databaseExists);

            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
            _serializer            = serializer;
            _options              = new Lazy <LiteDbMessageQueueTransportOptions>(optionsFactory.Create);
            _headers              = headers;
            _configurationSend    = configurationSend;
            _sendJobStatus        = sendJobStatus;
            _jobExistsHandler     = jobExistsHandler;
            _jobSchedulerMetaData = jobSchedulerMetaData;
            _databaseExists       = databaseExists;
        }
        /// <inheritdoc />
        public bool Create(LiteDbConnectionManager connection, LiteDbMessageQueueTransportOptions options,
                           TableNameHelper helper)
        {
            using (var db = connection.GetDatabase())
            {
                var col = db.Database.GetCollection <MetaDataTable>(helper.MetaDataName);

                col.EnsureIndex(x => x.Id);
                col.EnsureIndex(x => x.QueueId, true);

                if (options.EnableStatus)
                {
                    col.EnsureIndex(x => x.Status);
                }
                if (options.EnableMessageExpiration)
                {
                    col.EnsureIndex(x => x.ExpirationTime);
                }
                if (options.EnableHeartBeat)
                {
                    col.EnsureIndex(x => x.HeartBeat);
                }
                if (options.EnableRoute)
                {
                    col.EnsureIndex(x => x.Route);
                }

                return(true);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ResetHeartBeatCommandHandler"/> class.
        /// </summary>
        /// <param name="tableNameHelper">The table name helper.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public ResetHeartBeatCommandHandler(TableNameHelper tableNameHelper,
                                            LiteDbConnectionManager connectionInformation)
        {
            _tableNameHelper       = tableNameHelper;
            _connectionInformation = connectionInformation;

            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FindExpiredRecordsToDeleteQueryHandler"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        public FindExpiredRecordsToDeleteQueryHandler(LiteDbConnectionManager connectionInformation,
                                                      TableNameHelper tableNameHelper)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);

            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SendHeartBeatCommandHandler" /> class.
        /// </summary>
        public SendHeartBeatCommandHandler(LiteDbConnectionManager connectionInformation,
                                           TableNameHelper tableNameHelper)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);

            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GetMessageErrorsQueryHandler"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        public GetMessageErrorsQueryHandler(LiteDbConnectionManager connectionInformation,
                                            TableNameHelper tableNameHelper)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);

            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GetJobLastKnownEventQueryHandler"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        public GetJobLastKnownEventQueryHandler(LiteDbConnectionManager connectionInformation,
                                                TableNameHelper tableNameHelper)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);

            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DeleteQueueTablesCommandHandler"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        public DeleteQueueTablesCommandHandler(
            LiteDbConnectionManager connectionInformation,
            TableNameHelper tableNameHelper)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);

            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FindErrorRecordsToDeleteQueryHandler"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        /// <param name="configuration">The configuration.</param>
        public FindErrorRecordsToDeleteQueryHandler(LiteDbConnectionManager connectionInformation,
                                                    TableNameHelper tableNameHelper,
                                                    IMessageErrorConfiguration configuration)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => configuration, configuration);

            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
            _configuration         = configuration;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GetHeaderQueryHandler"/> class.
        /// </summary>
        /// <param name="serialization">The serialization.</param>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        public GetHeaderQueryHandler(ICompositeSerialization serialization,
                                     LiteDbConnectionManager connectionInformation,
                                     TableNameHelper tableNameHelper)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => serialization, serialization);

            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
            _serialization         = serialization;
        }
Exemplo n.º 11
0
        /// <inheritdoc />
        public bool Create(LiteDbConnectionManager connection, LiteDbMessageQueueTransportOptions options, TableNameHelper helper)
        {
            var db = connection.GetDatabase();
            {
                var col = db.Database.GetCollection <QueueTable>(helper.QueueName);

                //indexed by Id
                col.EnsureIndex(x => x.Id);

                return(true);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateJobTablesCommandHandler"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="optionsFactory">The options factory.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        public CreateJobTablesCommandHandler(LiteDbConnectionManager connectionInformation,
                                             ILiteDbMessageQueueTransportOptionsFactory optionsFactory,
                                             TableNameHelper tableNameHelper)
        {
            Guard.NotNull(() => optionsFactory, optionsFactory);
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);

            _options = new Lazy <LiteDbMessageQueueTransportOptions>(optionsFactory.Create);
            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
        }
Exemplo n.º 13
0
        /// <inheritdoc />
        public bool Create(LiteDbConnectionManager connection, LiteDbMessageQueueTransportOptions options,
                           TableNameHelper helper)
        {
            using (var db = connection.GetDatabase())
            {
                var col = db.Database.GetCollection <ErrorTrackingTable>(helper.ErrorTrackingName);

                col.EnsureIndex(x => x.Id);
                col.EnsureIndex(x => x.QueueId, false); //multiple exceptions per record are possible

                return(true);
            }
        }
Exemplo n.º 14
0
        /// <inheritdoc />
        public bool Create(LiteDbConnectionManager connection, LiteDbMessageQueueTransportOptions options,
                           TableNameHelper helper)
        {
            using (var db = connection.GetDatabase())
            {
                var col = db.Database.GetCollection <MetaDataErrorsTable>(helper.MetaDataErrorsName);

                col.EnsureIndex(x => x.Id);
                col.EnsureIndex(x => x.QueueId, true);

                return(true);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateQueueTablesAndSaveConfigurationCommandHandler"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="optionsFactory">The options factory.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        /// <param name="serializer">The serializer.</param>
        public CreateQueueTablesAndSaveConfigurationCommandHandler(LiteDbConnectionManager connectionInformation,
                                                                   ILiteDbMessageQueueTransportOptionsFactory optionsFactory,
                                                                   TableNameHelper tableNameHelper,
                                                                   IInternalSerializer serializer)
        {
            Guard.NotNull(() => optionsFactory, optionsFactory);
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => serializer, serializer);

            _options = new Lazy <LiteDbMessageQueueTransportOptions>(optionsFactory.Create);
            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
            _serializer            = serializer;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FindRecordsToResetByHeartBeatQueryHandler"/> class.
        /// </summary>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="serialization">The serialization.</param>
        public FindRecordsToResetByHeartBeatQueryHandler(LiteDbConnectionManager connectionInformation,
                                                         TableNameHelper tableNameHelper,
                                                         IHeartBeatConfiguration configuration,
                                                         ICompositeSerialization serialization)
        {
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => configuration, configuration);
            Guard.NotNull(() => serialization, serialization);

            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
            _configuration         = configuration;
            _serialization         = serialization;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GetQueueOptionsQueryHandler{TTransportOptions}" /> class.
        /// </summary>
        /// <param name="serializer">The serializer.</param>
        /// <param name="tableExists">The table exists.</param>
        /// <param name="connectionInformation">The connection information.</param>
        /// <param name="tableNameHelper">The table name helper.</param>
        public GetQueueOptionsQueryHandler(IInternalSerializer serializer,
                                           IQueryHandler <GetTableExistsQuery, bool> tableExists,
                                           LiteDbConnectionManager connectionInformation,
                                           TableNameHelper tableNameHelper)
        {
            Guard.NotNull(() => serializer, serializer);
            Guard.NotNull(() => tableExists, tableExists);
            Guard.NotNull(() => connectionInformation, connectionInformation);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);

            _serializer            = serializer;
            _tableExists           = tableExists;
            _connectionInformation = connectionInformation;
            _tableNameHelper       = tableNameHelper;
        }
        /// <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="connectionInformation">The connection information.</param>
        /// <param name="databaseExists">The database exists.</param>
        /// <param name="messageDeQueue">The message de queue.</param>
        public ReceiveMessageQueryHandler(ILiteDbMessageQueueTransportOptionsFactory optionsFactory,
                                          TableNameHelper tableNameHelper,
                                          LiteDbConnectionManager connectionInformation,
                                          DatabaseExists databaseExists,
                                          MessageDeQueue messageDeQueue)
        {
            Guard.NotNull(() => optionsFactory, optionsFactory);
            Guard.NotNull(() => tableNameHelper, tableNameHelper);
            Guard.NotNull(() => databaseExists, databaseExists);
            Guard.NotNull(() => messageDeQueue, messageDeQueue);
            Guard.NotNull(() => connectionInformation, connectionInformation);

            _options               = new Lazy <LiteDbMessageQueueTransportOptions>(optionsFactory.Create);
            _tableNameHelper       = tableNameHelper;
            _connectionInformation = connectionInformation;
            _databaseExists        = databaseExists;
            _messageDeQueue        = messageDeQueue;
        }
Exemplo n.º 19
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;
        }