public void Readonly() { var test = new SqLiteMessageQueueTransportOptions(); test.SetReadOnly(); Assert.True(test.IsReadOnly); }
internal void BuildCommand(SQLiteCommand selectCommand, IMessageId messageId, CommandString commandString, SqLiteMessageQueueTransportOptions options, List<string> routes ) { if (messageId != null && messageId.HasValue) { selectCommand.CommandText = commandString.CommandText; selectCommand.Parameters.Add("@QueueID", DbType.Int64); selectCommand.Parameters.Add("@CurrentDateTime", DbType.Int64); selectCommand.Parameters["@QueueID"].Value = messageId.Id.Value; selectCommand.Parameters["@CurrentDateTime"].Value = _getTime.GetCurrentUtcDate().Ticks; } else { selectCommand.CommandText = commandString.CommandText; selectCommand.Parameters.Add("@CurrentDateTime", DbType.Int64); selectCommand.Parameters["@CurrentDateTime"].Value = _getTime.GetCurrentUtcDate().Ticks; } if (options.EnableRoute && routes != null && routes.Count > 0) { var routeCounter = 1; foreach (var route in routes) { selectCommand.Parameters.Add("@Route" + routeCounter.ToString(), DbType.AnsiString); selectCommand.Parameters["@Route" + routeCounter.ToString()].Value = route; routeCounter++; } } }
public void GetSet_Priority() { var test = new SqLiteMessageQueueTransportOptions(); var c = test.EnablePriority; test.EnablePriority = !c; Assert.Equal(!c, test.EnablePriority); }
internal void BuildCommand(IDbCommand selectCommand, CommandString commandString, SqLiteMessageQueueTransportOptions options, List <string> routes) { selectCommand.CommandText = commandString.CommandText; var paramDate = selectCommand.CreateParameter(); paramDate.ParameterName = "@CurrentDateTime"; paramDate.DbType = DbType.Int64; paramDate.Value = _getTime.GetCurrentUtcDate().Ticks; selectCommand.Parameters.Add(paramDate); if (options.EnableRoute && routes != null && routes.Count > 0) { var routeCounter = 1; foreach (var route in routes) { var param = selectCommand.CreateParameter(); param.ParameterName = "@Route" + routeCounter; param.DbType = DbType.AnsiString; param.Value = route; selectCommand.Parameters.Add(param); routeCounter++; } } }
public void GetSet_EnableHeartBeat() { var test = new SqLiteMessageQueueTransportOptions(); var c = test.EnableHeartBeat; test.EnableHeartBeat = !c; Assert.Equal(!c, test.EnableHeartBeat); }
public void GetSet_EnableStatusTable() { var test = new SqLiteMessageQueueTransportOptions(); var c = test.EnableStatusTable; test.EnableStatusTable = !c; Assert.Equal(!c, test.EnableStatusTable); }
public void GetSet_EnableDelayedProcessing() { var test = new SqLiteMessageQueueTransportOptions(); var c = test.EnableDelayedProcessing; test.EnableDelayedProcessing = !c; Assert.Equal(!c, test.EnableDelayedProcessing); }
public void GetSet_EnableDelayedProcessing() { var test = new SqLiteMessageQueueTransportOptions(); var c = test.EnableDelayedProcessing; test.EnableDelayedProcessing = !c; Assert.Equal(!c, test.EnableDelayedProcessing); }
public void GetSet_EnableStatusTable() { var test = new SqLiteMessageQueueTransportOptions(); var c = test.EnableStatusTable; test.EnableStatusTable = !c; Assert.Equal(!c, test.EnableStatusTable); }
public void GetSet_EnableMessageExpiration() { var test = new SqLiteMessageQueueTransportOptions(); var c = test.EnableMessageExpiration; test.EnableMessageExpiration = !c; Assert.Equal(!c, test.EnableMessageExpiration); }
public void GetSet_QueueType() { var test = new SqLiteMessageQueueTransportOptions { QueueType = QueueTypes.RpcReceive }; Assert.Equal(QueueTypes.RpcReceive, test.QueueType); }
private SqLiteMessageQueueSchema Create() { var options = new SqLiteMessageQueueTransportOptions(); var factory = Substitute.For <ISqLiteMessageQueueTransportOptionsFactory>(); factory.Create().Returns(options); return(Create(factory)); }
public void GetSet_EnableHeartBeat() { var test = new SqLiteMessageQueueTransportOptions(); var c = test.EnableHeartBeat; test.EnableHeartBeat = !c; Assert.Equal(!c, test.EnableHeartBeat); }
public void GetSet_Priority() { var test = new SqLiteMessageQueueTransportOptions(); var c = test.EnablePriority; test.EnablePriority = !c; Assert.Equal(!c, test.EnablePriority); }
internal static IDbCommand CreateMetaDataRecord(TimeSpan?delay, TimeSpan expiration, IDbConnection connection, IMessage message, IAdditionalMessageData data, TableNameHelper tableNameHelper, IHeaders headers, SqLiteMessageQueueTransportOptions options, IGetTime getTime) { var command = connection.CreateCommand(); BuildMetaCommand(command, tableNameHelper, data, options, delay, expiration, getTime.GetCurrentUtcDate()); return(command); }
internal static SQLiteCommand CreateMetaDataRecord(TimeSpan? delay, TimeSpan expiration, SQLiteConnection connection, IMessage message, IAdditionalMessageData data, TableNameHelper tableNameHelper, IHeaders headers, SqLiteMessageQueueTransportOptions options, IGetTime getTime) { var command = new SQLiteCommand(connection); BuildMetaCommand(command, tableNameHelper, headers, data, message, 0, options, delay, expiration, getTime.GetCurrentUtcDate()); return command; }
public void Create_Status() { var tableName = GetTableNameHelper(); var options = new SqLiteMessageQueueTransportOptions { EnableStatusTable = true}; var factory = Substitute.For<ISqLiteMessageQueueTransportOptionsFactory>(); factory.Create().Returns(options); var test = Create(factory, tableName); var tables = test.GetSchema(); Assert.True(tables.Any(item => item.Name == tableName.StatusName)); }
internal static void BuildStatusCommand(IDbCommand command, TableNameHelper tableNameHelper, IHeaders headers, IAdditionalMessageData data, IMessage message, long id, SqLiteMessageQueueTransportOptions options, DateTime currentDateTime) { var builder = new StringBuilder(); builder.AppendLine("Insert into " + tableNameHelper.StatusName); builder.Append("(QueueID, Status, CorrelationID "); //add configurable columns - user AddUserColumns(builder, data); //close the column list builder.AppendLine(") "); //add standard values that are always present builder.Append("VALUES ("); builder.Append($"@QueueID, {Convert.ToInt32(QueueStatuses.Waiting)}, @CorrelationID"); //add configurable column value - user AddUserColumnsValues(builder, data); builder.Append(")"); //close the VALUES command.CommandText = builder.ToString(); options.AddBuiltInColumnsParams(command, data, null, TimeSpan.Zero, currentDateTime); if (id > 0) { var paramid = command.CreateParameter(); paramid.ParameterName = "@QueueID"; paramid.DbType = DbType.Int64; paramid.Value = id; command.Parameters.Add(paramid); } var param = command.CreateParameter(); param.ParameterName = "@CorrelationID"; param.DbType = DbType.StringFixedLength; param.Size = 38; param.Value = data.CorrelationId.Id.Value.ToString(); command.Parameters.Add(param); //add configurable column command params - user AddUserColumnsParams(command, data); AddHeaderColumnParams(command, message, headers); }
public void Create_Meta_Priority() { var tableName = GetTableNameHelper(); var options = new SqLiteMessageQueueTransportOptions { EnablePriority = true}; var factory = Substitute.For<ISqLiteMessageQueueTransportOptionsFactory>(); factory.Create().Returns(options); var test = Create(factory, tableName); var tables = test.GetSchema(); var statusTable = tables.Find(item => item.Name == tableName.MetaDataName); Assert.True(statusTable.Columns.Items.Any(item => item.Name == "Priority")); }
public void Create_Status_Extra_Columns() { var tableName = GetTableNameHelper(); var options = new SqLiteMessageQueueTransportOptions { EnableStatusTable = true}; options.AdditionalColumns.Add(new Column("testing", ColumnTypes.Integer, true, null)); var factory = Substitute.For<ISqLiteMessageQueueTransportOptionsFactory>(); factory.Create().Returns(options); var test = Create(factory, tableName); var tables = test.GetSchema(); var statusTable = tables.Find(item => item.Name == tableName.StatusName); Assert.True(statusTable.Columns.Items.Any(item => item.Name == "testing")); }
public void Create_Status() { var tableName = GetTableNameHelper(); var options = new SqLiteMessageQueueTransportOptions { EnableStatusTable = true }; var factory = Substitute.For <ISqLiteMessageQueueTransportOptionsFactory>(); factory.Create().Returns(options); var test = Create(factory, tableName); var tables = test.GetSchema().ConvertAll(o => (Table)o); Assert.Contains(tables, item => item.Name == tableName.StatusName); }
public void Create_Meta_Priority() { var tableName = GetTableNameHelper(); var options = new SqLiteMessageQueueTransportOptions { EnablePriority = true }; var factory = Substitute.For <ISqLiteMessageQueueTransportOptionsFactory>(); factory.Create().Returns(options); var test = Create(factory, tableName); var tables = test.GetSchema().ConvertAll(o => (Table)o); var statusTable = tables.Find(item => item.Name == tableName.MetaDataName); Assert.Contains(statusTable.Columns.Items, item => item.Name == "Priority"); }
public void Create_FIFO() { var tableName = GetTableNameHelper(); var options = new SqLiteMessageQueueTransportOptions { EnableStatus = false, EnableHeartBeat = false, EnablePriority = false }; var factory = Substitute.For <ISqLiteMessageQueueTransportOptionsFactory>(); factory.Create().Returns(options); var test = Create(factory, tableName); var tables = test.GetSchema(); Assert.NotNull(tables); }
private static void BuildMetaCommand(IDbCommand command, TableNameHelper tableNameHelper, IAdditionalMessageData data, SqLiteMessageQueueTransportOptions options, TimeSpan?delay, TimeSpan expiration, DateTime currentDateTime) { var sbMeta = new StringBuilder(); sbMeta.AppendLine("Insert into " + tableNameHelper.MetaDataName); sbMeta.Append("(QueueID, CorrelationID, QueuedDateTime "); //add configurable columns - queue options.AddBuiltInColumns(sbMeta); //close the column list sbMeta.AppendLine(") "); //add standard values that are always present sbMeta.Append("VALUES ("); sbMeta.Append("@QueueID, @CorrelationID, @CurrentDate "); //add the values for built in fields options.AddBuiltInColumnValues(sbMeta); sbMeta.Append(")"); //close the VALUES command.CommandText = sbMeta.ToString(); options.AddBuiltInColumnsParams(command, data, delay, expiration, currentDateTime); var param = command.CreateParameter(); param.ParameterName = "@CorrelationID"; param.DbType = DbType.StringFixedLength; param.Size = 38; param.Value = data.CorrelationId.Id.Value.ToString(); command.Parameters.Add(param); param = command.CreateParameter(); param.ParameterName = "@CurrentDate"; param.DbType = DbType.Int64; param.Value = currentDateTime.Ticks; command.Parameters.Add(param); }
public void Create_Status_Extra_Columns() { var tableName = GetTableNameHelper(); var options = new SqLiteMessageQueueTransportOptions { EnableStatusTable = true }; options.AdditionalColumns.Add(new Column("testing", ColumnTypes.Integer, true, null)); var factory = Substitute.For <ISqLiteMessageQueueTransportOptionsFactory>(); factory.Create().Returns(options); var test = Create(factory, tableName); var tables = test.GetSchema().ConvertAll(o => (Table)o); var statusTable = tables.Find(item => item.Name == tableName.StatusName); Assert.Contains(statusTable.Columns.Items, item => item.Name == "testing"); }
/// <summary> /// Creates new instance. /// </summary> /// <returns></returns> public SqLiteMessageQueueTransportOptions Create() { if (string.IsNullOrEmpty(_connectionInformation.ConnectionString)) { return new SqLiteMessageQueueTransportOptions(); } if (_options != null) return _options; lock (_creator) { if (_options == null) { _options = _queryOptions.Handle(new GetQueueOptionsQuery()); } if (_options == null) //does not exist in DB; return a new copy { _options = new SqLiteMessageQueueTransportOptions(); } } return _options; }
internal static void BuildStatusCommand(SQLiteCommand command, TableNameHelper tableNameHelper, IHeaders headers, IAdditionalMessageData data, IMessage message, long id, SqLiteMessageQueueTransportOptions options, DateTime currentDateTime) { var builder = new StringBuilder(); builder.AppendLine("Insert into " + tableNameHelper.StatusName); builder.Append("(QueueID, Status, CorrelationID "); //add configurable columns - user AddUserColumns(builder, data); //close the column list builder.AppendLine(") "); //add standard values that are always present builder.Append("VALUES ("); builder.Append($"@QueueID, {Convert.ToInt32(QueueStatuses.Waiting)}, @CorrelationID"); //add configurable column value - user AddUserColumnsValues(builder, data); builder.Append(")"); //close the VALUES command.CommandText = builder.ToString(); options.AddBuiltInColumnsParams(command, data, null, TimeSpan.Zero, currentDateTime); command.Parameters.Add("@QueueID", DbType.Int64, 8).Value = id; command.Parameters.Add("@CorrelationID", DbType.StringFixedLength, 38).Value = data.CorrelationId.Id.Value.ToString(); //add configurable column command params - user AddUserColumnsParams(command, data); AddHeaderColumnParams(command, message, headers); }
/// <summary> /// Creates new instance. /// </summary> /// <returns></returns> public SqLiteMessageQueueTransportOptions Create() { if (string.IsNullOrEmpty(_connectionInformation.ConnectionString)) { return(new SqLiteMessageQueueTransportOptions()); } if (_options != null) { return(_options); } lock (_creator) { if (_options == null) { _options = _queryOptions.Handle(new GetQueueOptionsQuery <SqLiteMessageQueueTransportOptions>()); } if (_options == null) //does not exist in DB; return a new copy { _options = new SqLiteMessageQueueTransportOptions(); } } return(_options); }
public void Create_FIFO() { var tableName = GetTableNameHelper(); var options = new SqLiteMessageQueueTransportOptions { EnableStatus = false, EnableHeartBeat = false, EnablePriority = false }; var factory = Substitute.For<ISqLiteMessageQueueTransportOptionsFactory>(); factory.Create().Returns(options); var test = Create(factory, tableName); var tables = test.GetSchema(); Assert.NotNull(tables); }
public void GetSet_QueueType() { var test = new SqLiteMessageQueueTransportOptions { QueueType = QueueTypes.RpcReceive}; Assert.Equal(QueueTypes.RpcReceive, test.QueueType); }
public void GetSet_EnableMessageExpiration() { var test = new SqLiteMessageQueueTransportOptions(); var c = test.EnableMessageExpiration; test.EnableMessageExpiration = !c; Assert.Equal(!c, test.EnableMessageExpiration); }
/// <summary> /// Gets the de queue command. /// </summary> /// <param name="metaTableName">Name of the meta table.</param> /// <param name="queueTableName">Name of the queue table.</param> /// <param name="forRpc">if set to <c>true</c> [for RPC].</param> /// <param name="statusTableName">Name of the status table.</param> /// <param name="options">The options.</param> /// <param name="routes">The routes.</param> /// <returns></returns> public static CommandString GetDeQueueCommand(string metaTableName, string queueTableName, bool forRpc, string statusTableName, SqLiteMessageQueueTransportOptions options, List <string> routes) { var sb = new StringBuilder(); var tempName = GenerateTempTableName(); sb.AppendLine($"CREATE TEMP TABLE {tempName}(QueueID Integer PRIMARY KEY, CurrentDateTime Integer);"); sb.AppendLine($"Insert into {tempName} (QueueID, CurrentDateTime)"); sb.AppendLine("select "); sb.AppendLine(metaTableName + ".QueueID, "); sb.AppendLine("@CurrentDateTime"); sb.AppendLine($"from {metaTableName} "); //calculate where clause... var needWhere = true; if (options.EnableStatus && options.EnableDelayedProcessing) { sb.Append($" WHERE {metaTableName}.Status = {Convert.ToInt16(QueueStatuses.Waiting)} "); sb.AppendLine("and QueueProcessTime < @CurrentDateTime "); needWhere = false; } else if (options.EnableStatus) { sb.Append($" WHERE {metaTableName}.Status = {Convert.ToInt16(QueueStatuses.Waiting)} "); needWhere = false; } else if (options.EnableDelayedProcessing) { sb.AppendLine("WHERE (QueueProcessTime < @CurrentDateTime) "); needWhere = false; } if (forRpc) { if (needWhere) { sb.AppendLine("Where SourceQueueID = @QueueID "); needWhere = false; } else { sb.AppendLine("AND SourceQueueID = @QueueID "); } } if (options.EnableMessageExpiration || options.QueueType == QueueTypes.RpcReceive || options.QueueType == QueueTypes.RpcSend) { if (needWhere) { sb.AppendLine("where ExpirationTime > @CurrentDateTime "); needWhere = false; } else { sb.AppendLine("AND ExpirationTime > @CurrentDateTime "); } } if (options.EnableRoute && routes != null && routes.Count > 0) { sb.AppendLine(needWhere ? "where Route IN ( " : "AND Route IN ( "); for (var i = 1; i - 1 < routes.Count; i++) { sb.Append("@Route" + i); if (i != routes.Count) { sb.Append(", "); } } sb.Append(") "); } //determine order by looking at the options var bNeedComma = false; sb.Append(" Order by "); if (options.EnableStatus) { sb.Append(" status asc "); bNeedComma = true; } if (options.EnablePriority) { if (bNeedComma) { sb.Append(", "); } sb.Append(" priority asc "); bNeedComma = true; } if (options.EnableDelayedProcessing) { if (bNeedComma) { sb.Append(", "); } sb.AppendLine(" QueueProcessTime asc "); bNeedComma = true; } if (options.EnableMessageExpiration) { if (bNeedComma) { sb.Append(", "); } sb.AppendLine(" ExpirationTime asc "); bNeedComma = true; } if (bNeedComma) { sb.Append(", "); } sb.AppendLine($" {metaTableName}.QueueID asc "); sb.AppendLine(" LIMIT 1;"); //---------------------------- sb.AppendLine(""); sb.AppendLine("select "); sb.AppendLine($"{tempName}.QueueID, {metaTableName}.CorrelationID, {queueTableName}.Body, {queueTableName}.Headers "); if (options.EnableStatus) { sb.Append($", {metaTableName}.status "); } if (options.EnableHeartBeat) { sb.Append($", {metaTableName}.HeartBeat "); } sb.AppendLine($"from {tempName} "); sb.AppendLine($"JOIN {metaTableName} "); sb.AppendLine($"ON {metaTableName}.QueueID = {tempName}.QueueID "); sb.AppendLine($"JOIN {queueTableName} "); sb.AppendLine($"ON {metaTableName}.QueueID = {queueTableName}.QueueID; "); sb.AppendLine(""); var additionalCommands = new List <string>(); //determine if performing update or delete... var status = new StringBuilder(); if (options.EnableStatus) { //update status.Append($"update {metaTableName} set status = {Convert.ToInt16(QueueStatuses.Processing)} "); if (options.EnableHeartBeat) { status.AppendLine($", HeartBeat = (select {tempName}.CurrentDateTime from {tempName} LIMIT 1) "); } status.Append($" where {metaTableName}.QueueID = (select {tempName}.QueueID from {tempName} LIMIT 1);"); } else { //delete - note even if heartbeat is enabled, there is no point in setting it //a delete here if not using transactions will actually remove the record from the queue //it's up to the caller to handle error conditions in this case. status.AppendLine($"delete from {metaTableName} where {metaTableName}.QueueID = (select {tempName}.QueueID from {tempName} LIMIT 1); "); } additionalCommands.Add(status.ToString()); if (options.EnableStatusTable) { additionalCommands.Add($" update {statusTableName} set status = {Convert.ToInt16(QueueStatuses.Processing)} where {statusTableName}.QueueID = (select {tempName}.QueueID from {tempName} LIMIT 1);"); } //will drop when the connection closes //additionalCommands.Add($"drop table {tempName};"); return(new CommandString(sb.ToString(), additionalCommands)); }
internal static void BuildMetaCommand(SQLiteCommand command, TableNameHelper tableNameHelper, IHeaders headers, IAdditionalMessageData data, IMessage message, long id, SqLiteMessageQueueTransportOptions options, TimeSpan? delay, TimeSpan expiration, DateTime currentDateTime) { var sbMeta = new StringBuilder(); sbMeta.AppendLine("Insert into " + tableNameHelper.MetaDataName); sbMeta.Append("(QueueID, CorrelationID, QueuedDateTime "); //add configurable columns - queue options.AddBuiltInColumns(sbMeta); AddHeaderColumns(sbMeta, message, headers); //close the column list sbMeta.AppendLine(") "); //add standard values that are always present sbMeta.Append("VALUES ("); sbMeta.Append("@QueueID, @CorrelationID, @CurrentDate "); //add the values for built in fields options.AddBuiltInColumnValues(delay, expiration, sbMeta); AddHeaderValues(sbMeta, message, headers); sbMeta.Append(")"); //close the VALUES command.CommandText = sbMeta.ToString(); options.AddBuiltInColumnsParams(command, data, delay, expiration, currentDateTime); AddHeaderColumnParams(command, message, headers); command.Parameters.Add("@QueueID", DbType.Int64, 8).Value = id; command.Parameters.Add("@CorrelationID", DbType.StringFixedLength, 38).Value = data.CorrelationId.Id.Value.ToString(); command.Parameters.Add("@CurrentDate", DbType.Int64).Value = currentDateTime.Ticks; }
public void Test_DefaultNotReadOnly() { var test = new SqLiteMessageQueueTransportOptions(); Assert.False(test.IsReadOnly); }
/// <summary> /// Gets the de queue command. /// </summary> /// <param name="metaTableName">Name of the meta table.</param> /// <param name="queueTableName">Name of the queue table.</param> /// <param name="forRpc">if set to <c>true</c> [for RPC].</param> /// <param name="statusTableName">Name of the status table.</param> /// <param name="options">The options.</param> /// <param name="routes">The routes.</param> /// <returns></returns> public static CommandString GetDeQueueCommand(string metaTableName, string queueTableName, bool forRpc, string statusTableName, SqLiteMessageQueueTransportOptions options, List<string> routes ) { var sb = new StringBuilder(); var tempName = GenerateTempTableName(); sb.AppendLine($"CREATE TEMP TABLE {tempName}(QueueID Integer PRIMARY KEY, CurrentDateTime Integer);"); sb.AppendLine($"Insert into {tempName} (QueueID, CurrentDateTime)"); sb.AppendLine("select "); sb.AppendLine(metaTableName + ".QueueID, "); sb.AppendLine("@CurrentDateTime"); sb.AppendLine($"from {metaTableName} "); //calculate where clause... var needWhere = true; if (options.EnableStatus && options.EnableDelayedProcessing) { sb.Append($" WHERE {metaTableName}.Status = {Convert.ToInt16(QueueStatuses.Waiting)} "); sb.AppendLine("and QueueProcessTime < @CurrentDateTime "); needWhere = false; } else if (options.EnableStatus) { sb.Append($" WHERE {metaTableName}.Status = {Convert.ToInt16(QueueStatuses.Waiting)} "); needWhere = false; } else if (options.EnableDelayedProcessing) { sb.AppendLine("WHERE (QueueProcessTime < @CurrentDateTime) "); needWhere = false; } if (forRpc) { if (needWhere) { sb.AppendLine("Where SourceQueueID = @QueueID "); needWhere = false; } else { sb.AppendLine("AND SourceQueueID = @QueueID "); } } if (options.EnableMessageExpiration || options.QueueType == QueueTypes.RpcReceive || options.QueueType == QueueTypes.RpcSend) { if (needWhere) { sb.AppendLine("where ExpirationTime > getutcdate() "); needWhere = false; } else { sb.AppendLine("AND ExpirationTime > getutcdate() "); } needWhere = false; } if (options.EnableRoute && routes != null && routes.Count > 0) { if (needWhere) { sb.AppendLine("where Route IN ( "); needWhere = false; } else { sb.AppendLine("AND Route IN ( "); } var routeCounter = 1; foreach (var route in routes) { sb.Append("@Route" + routeCounter.ToString()); routeCounter++; if (routeCounter != routes.Count + 1) { sb.Append(", "); } } sb.Append(") "); } //determine order by looking at the options var bNeedComma = false; sb.Append(" Order by "); if (options.EnableStatus) { sb.Append(" status asc "); bNeedComma = true; } if (options.EnablePriority) { if (bNeedComma) { sb.Append(", "); } sb.Append(" priority asc "); bNeedComma = true; } if (options.EnableDelayedProcessing) { if (bNeedComma) { sb.Append(", "); } sb.AppendLine(" QueueProcessTime asc "); bNeedComma = true; } if (options.EnableMessageExpiration) { if (bNeedComma) { sb.Append(", "); } sb.AppendLine(" ExpirationTime asc "); bNeedComma = true; } if (bNeedComma) { sb.Append(", "); } sb.AppendLine($" {metaTableName}.QueueID asc "); sb.AppendLine(" LIMIT 1;"); //---------------------------- sb.AppendLine(""); sb.AppendLine("select "); sb.AppendLine($"{tempName}.QueueID, {metaTableName}.CorrelationID, {queueTableName}.Body, {queueTableName}.Headers "); if (options.EnableStatus) { sb.Append($", {metaTableName}.status "); } if (options.EnableHeartBeat) { sb.Append($", {metaTableName}.HeartBeat "); } sb.AppendLine($"from {tempName} "); sb.AppendLine($"JOIN {metaTableName} "); sb.AppendLine($"ON {metaTableName}.QueueID = {tempName}.QueueID "); sb.AppendLine($"JOIN {queueTableName} "); sb.AppendLine($"ON {metaTableName}.QueueID = {queueTableName}.QueueID; "); sb.AppendLine(""); List<string> additionalCommands = new List<string>(); //determine if performing update or delete... var status = new StringBuilder(); if (options.EnableStatus) { //update status.Append($"update {metaTableName} set status = {Convert.ToInt16(QueueStatuses.Processing)} "); if (options.EnableHeartBeat) { status.AppendLine($", HeartBeat = (select {tempName}.CurrentDateTime from {tempName} LIMIT 1) "); } status.Append($" where {metaTableName}.QueueID = (select {tempName}.QueueID from {tempName} LIMIT 1);"); } else { //delete - note even if heartbeat is enabled, there is no point in setting it //a delete here if not using transactions will actually remove the record from the queue //it's up to the caller to handle error conditions in this case. status.AppendLine($"delete from {metaTableName} where {metaTableName}.QueueID = (select {tempName}.QueueID from {tempName} LIMIT 1); "); } additionalCommands.Add(status.ToString()); if (options.EnableStatusTable) { additionalCommands.Add($" update {statusTableName} set status = {Convert.ToInt16(QueueStatuses.Processing)} where {statusTableName}.QueueID = (select {tempName}.QueueID from {tempName} LIMIT 1);"); } //will drop when the connection closes //additionalCommands.Add($"drop table {tempName};"); return new CommandString(sb.ToString(), additionalCommands); }
public void Readonly() { var test = new SqLiteMessageQueueTransportOptions(); test.SetReadOnly(); Assert.True(test.IsReadOnly); }
public void Test_DefaultNotReadOnly() { var test = new SqLiteMessageQueueTransportOptions(); Assert.False(test.IsReadOnly); }
public void Validation() { var test = new SqLiteMessageQueueTransportOptions(); test.ValidConfiguration(); }
public VerifyQueueData(string queueName, string connectionString, SqLiteMessageQueueTransportOptions options) { _options = options; _connection = new SqliteConnectionInformation(queueName, connectionString); _tableNameHelper = new TableNameHelper(_connection); }
public void Validation() { var test = new SqLiteMessageQueueTransportOptions(); test.ValidConfiguration(); }
private SqLiteMessageQueueSchema Create() { var options = new SqLiteMessageQueueTransportOptions(); var factory = Substitute.For<ISqLiteMessageQueueTransportOptionsFactory>(); factory.Create().Returns(options); return Create(factory); }
public VerifyQueueData(string queueName, string connectionString, SqLiteMessageQueueTransportOptions options) { _options = options; _connection = new SqliteConnectionInformation(queueName, connectionString, new DbDataSource()); _tableNameHelper = new TableNameHelper(_connection); }