diff --git a/src/DotNetCore.CAP.MySql/MySqlStorage.cs b/src/DotNetCore.CAP.MySql/MySqlStorage.cs index 98fa0de..e0170de 100644 --- a/src/DotNetCore.CAP.MySql/MySqlStorage.cs +++ b/src/DotNetCore.CAP.MySql/MySqlStorage.cs @@ -81,7 +81,11 @@ CREATE TABLE IF NOT EXISTS `{prefix}.published` ( `ExpiresAt` datetime DEFAULT NULL, `StatusName` varchar(40) NOT NULL, PRIMARY KEY (`Id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +ALTER TABLE `{prefix}.published` MODIFY Id BIGINT NOT NULL; +ALTER TABLE `{prefix}.received` MODIFY Id BIGINT NOT NULL; +"; return batchSql; } diff --git a/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs b/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs index b212178..97aadf6 100644 --- a/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs +++ b/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs @@ -30,7 +30,7 @@ namespace DotNetCore.CAP.MySql return new MySqlStorageTransaction(this); } - public async Task GetPublishedMessageAsync(int id) + public async Task GetPublishedMessageAsync(long id) { var sql = $@"SELECT * FROM `{_prefix}.published` WHERE `Id`={id};"; @@ -52,7 +52,7 @@ namespace DotNetCore.CAP.MySql } } - public Task StoreReceivedMessageAsync(CapReceivedMessage message) + public void StoreReceivedMessage(CapReceivedMessage message) { if (message == null) { @@ -60,16 +60,16 @@ namespace DotNetCore.CAP.MySql } var sql = $@" -INSERT INTO `{_prefix}.received`(`Name`,`Group`,`Content`,`Retries`,`Added`,`ExpiresAt`,`StatusName`) -VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);"; +INSERT INTO `{_prefix}.received`(`Id`,`Name`,`Group`,`Content`,`Retries`,`Added`,`ExpiresAt`,`StatusName`) +VALUES(@Id,@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);"; using (var connection = new MySqlConnection(Options.ConnectionString)) { - return connection.ExecuteScalarAsync(sql, message); + connection.Execute(sql, message); } } - public async Task GetReceivedMessageAsync(int id) + public async Task GetReceivedMessageAsync(long id) { var sql = $@"SELECT * FROM `{_prefix}.received` WHERE Id={id};"; using (var connection = new MySqlConnection(Options.ConnectionString)) @@ -89,7 +89,7 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);"; } } - public bool ChangePublishedState(int messageId, string state) + public bool ChangePublishedState(long messageId, string state) { var sql = $"UPDATE `{_prefix}.published` SET `Retries`=`Retries`+1,`ExpiresAt`=NULL,`StatusName` = '{state}' WHERE `Id`={messageId}"; @@ -100,7 +100,7 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);"; } } - public bool ChangeReceivedState(int messageId, string state) + public bool ChangeReceivedState(long messageId, string state) { var sql = $"UPDATE `{_prefix}.received` SET `Retries`=`Retries`+1,`ExpiresAt`=NULL,`StatusName` = '{state}' WHERE `Id`={messageId}"; diff --git a/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs b/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs index 9a51faa..34f3aee 100644 --- a/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs +++ b/src/DotNetCore.CAP/Dashboard/DashboardRoutes.cs @@ -82,14 +82,14 @@ namespace DotNetCore.CAP.Dashboard Routes.AddJsonResult("/published/message/(?.+)", x => { - var id = int.Parse(x.UriMatch.Groups["Id"].Value); + var id = long.Parse(x.UriMatch.Groups["Id"].Value); var message = x.Storage.GetConnection().GetPublishedMessageAsync(id) .GetAwaiter().GetResult(); return message.Content; }); Routes.AddJsonResult("/received/message/(?.+)", x => { - var id = int.Parse(x.UriMatch.Groups["Id"].Value); + var id = long.Parse(x.UriMatch.Groups["Id"].Value); var message = x.Storage.GetConnection().GetReceivedMessageAsync(id) .GetAwaiter().GetResult(); return message.Content; diff --git a/src/DotNetCore.CAP/Dashboard/Monitoring/MessageDto.cs b/src/DotNetCore.CAP/Dashboard/Monitoring/MessageDto.cs index 1a256ba..0baaec4 100644 --- a/src/DotNetCore.CAP/Dashboard/Monitoring/MessageDto.cs +++ b/src/DotNetCore.CAP/Dashboard/Monitoring/MessageDto.cs @@ -7,7 +7,7 @@ namespace DotNetCore.CAP.Dashboard.Monitoring { public class MessageDto { - public int Id { get; set; } + public long Id { get; set; } public string Group { get; set; } diff --git a/src/DotNetCore.CAP/IStorageConnection.cs b/src/DotNetCore.CAP/IStorageConnection.cs index b694737..e305f58 100644 --- a/src/DotNetCore.CAP/IStorageConnection.cs +++ b/src/DotNetCore.CAP/IStorageConnection.cs @@ -19,7 +19,7 @@ namespace DotNetCore.CAP /// Returns the message with the given id. /// /// The message's id. - Task GetPublishedMessageAsync(int id); + Task GetPublishedMessageAsync(long id); /// /// Returns executed failed messages. @@ -32,13 +32,13 @@ namespace DotNetCore.CAP /// Stores the message. /// /// The message to store. - Task StoreReceivedMessageAsync(CapReceivedMessage message); + void StoreReceivedMessage(CapReceivedMessage message); /// /// Returns the message with the given id. /// /// The message's id. - Task GetReceivedMessageAsync(int id); + Task GetReceivedMessageAsync(long id); /// /// Returns executed failed message. @@ -55,13 +55,13 @@ namespace DotNetCore.CAP /// /// Message id /// State name - bool ChangePublishedState(int messageId, string state); + bool ChangePublishedState(long messageId, string state); /// /// Change specified message's state of received message /// /// Message id /// State name - bool ChangeReceivedState(int messageId, string state); + bool ChangeReceivedState(long messageId, string state); } } \ No newline at end of file