Browse Source

fix table name prefix bug.

master
Savorboard 7 years ago
parent
commit
6d5c771274
2 changed files with 6 additions and 6 deletions
  1. +5
    -5
      src/DotNetCore.CAP.MySql/MySqlFetchedMessage.cs
  2. +1
    -1
      src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs

+ 5
- 5
src/DotNetCore.CAP.MySql/MySqlFetchedMessage.cs View File

@@ -6,14 +6,14 @@ namespace DotNetCore.CAP.MySql
{ {
public class MySqlFetchedMessage : IFetchedMessage public class MySqlFetchedMessage : IFetchedMessage
{ {
private readonly string _connectionString = null;
private readonly MySqlOptions _options;


public MySqlFetchedMessage(int messageId, MessageType type, string connectionString)
public MySqlFetchedMessage(int messageId, MessageType type, MySqlOptions options)
{ {
MessageId = messageId; MessageId = messageId;
MessageType = type; MessageType = type;


_connectionString = connectionString;
_options = options;
} }


public int MessageId { get; } public int MessageId { get; }
@@ -27,9 +27,9 @@ namespace DotNetCore.CAP.MySql


public void Requeue() public void Requeue()
{ {
using (var connection = new MySqlConnection(_connectionString))
using (var connection = new MySqlConnection(_options.ConnectionString))
{ {
connection.Execute("insert into `cap.queue`(`MessageId`,`MessageType`) values(@MessageId,@MessageType);"
connection.Execute($"insert into `{_options.TableNamePrefix}.queue`(`MessageId`,`MessageType`) values(@MessageId,@MessageType);"
, new {MessageId, MessageType }); , new {MessageId, MessageType });
} }
} }


+ 1
- 1
src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs View File

@@ -150,7 +150,7 @@ SELECT * FROM `{_prefix}.received` WHERE Id=LAST_INSERT_ID();";
if (fetchedMessage == null) if (fetchedMessage == null)
return null; return null;


return new MySqlFetchedMessage(fetchedMessage.MessageId, fetchedMessage.MessageType, Options.ConnectionString);
return new MySqlFetchedMessage(fetchedMessage.MessageId, fetchedMessage.MessageType, Options);
} }


public void Dispose() public void Dispose()


Loading…
Cancel
Save