Commit 730507d0 authored by yangxiaodong's avatar yangxiaodong

fixed issue #25.

parent c4a465cd
......@@ -12,9 +12,10 @@ namespace DotNetCore.CAP.Abstractions
protected IDbConnection DbConnection { get; set; }
protected IDbTransaction DbTranasaction { get; set; }
protected bool IsCapOpenedTrans { get; set; }
protected bool IsCapOpenedConn { get; set; }
protected bool IsUsingEF { get; set; }
protected IServiceProvider ServiceProvider { get; set; }
public void Publish<T>(string name, T contentObj)
{
CheckIsUsingEF(name);
......@@ -83,7 +84,10 @@ namespace DotNetCore.CAP.Abstractions
throw new ArgumentNullException(nameof(dbConnection));
if (dbConnection.State != ConnectionState.Open)
{
IsCapOpenedConn = true;
dbConnection.Open();
}
if (dbTransaction == null)
{
......@@ -122,8 +126,13 @@ namespace DotNetCore.CAP.Abstractions
{
dbTransaction.Commit();
dbTransaction.Dispose();
}
if (IsCapOpenedConn)
{
dbConnection.Dispose();
}
PublishQueuer.PulseEvent.Set();
}
......@@ -142,8 +151,12 @@ namespace DotNetCore.CAP.Abstractions
{
dbTransaction.Commit();
dbTransaction.Dispose();
}
if (IsCapOpenedConn)
{
dbConnection.Dispose();
}
PublishQueuer.PulseEvent.Set();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment