@@ -40,10 +40,6 @@ public void EnlistInDistributedTransactionIfNeeded(ISessionImplementor session)
40
40
41
41
session . TransactionContext = notification ;
42
42
43
- transaction . EnlistVolatile (
44
- new TransactionCompletionNotification ( session ) ,
45
- EnlistmentOptions . None ) ;
46
-
47
43
logger . DebugFormat ( "enlisted into DTC transaction: {0}" , transaction . IsolationLevel . ToString ( ) ) ;
48
44
session . AfterTransactionBegin ( null ) ;
49
45
}
@@ -108,63 +104,12 @@ void IEnlistmentNotification.Prepare(PreparingEnlistment preparingEnlistment)
108
104
{
109
105
preparingEnlistment . ForceRollback ( exception ) ;
110
106
}
111
- finally
112
- {
113
- _session = null ;
114
- try
115
- {
116
- if ( _transaction != null ) _transaction . Dispose ( ) ;
117
- }
118
- finally
119
- {
120
- _transaction = null ;
121
- }
122
- }
123
107
}
124
108
}
125
109
126
110
void IEnlistmentNotification . Commit ( Enlistment enlistment )
127
111
{
128
- enlistment . Done ( ) ;
129
- }
130
-
131
- void IEnlistmentNotification . Rollback ( Enlistment enlistment )
132
- {
133
- enlistment . Done ( ) ;
134
- }
135
-
136
- void IEnlistmentNotification . InDoubt ( Enlistment enlistment )
137
- {
138
- enlistment . Done ( ) ;
139
- }
140
-
141
- public void Dispose ( )
142
- {
143
- if ( ! ReferenceEquals ( _transaction , null ) )
144
- _transaction . Dispose ( ) ;
145
- _transaction = null ;
146
- if ( ! ReferenceEquals ( _session , null ) )
147
- _session . TransactionContext = null ;
148
- _session = null ;
149
- }
150
- }
151
-
152
- class TransactionCompletionNotification : IEnlistmentNotification
153
- {
154
- ISessionImplementor _session ;
155
-
156
- public TransactionCompletionNotification ( ISessionImplementor session )
157
- {
158
- _session = session ;
159
- }
160
-
161
- void IEnlistmentNotification . Prepare ( PreparingEnlistment preparingEnlistment )
162
- {
163
- preparingEnlistment . Prepared ( ) ;
164
- }
165
-
166
- void IEnlistmentNotification . Commit ( Enlistment enlistment )
167
- {
112
+ using ( this )
168
113
using ( new SessionIdLoggingContext ( _session . SessionId ) )
169
114
{
170
115
try
@@ -178,14 +123,14 @@ void IEnlistmentNotification.Commit(Enlistment enlistment)
178
123
}
179
124
finally
180
125
{
181
- _session = null ;
182
126
enlistment . Done ( ) ;
183
127
}
184
128
}
185
129
}
186
130
187
131
void IEnlistmentNotification . Rollback ( Enlistment enlistment )
188
132
{
133
+ using ( this )
189
134
using ( new SessionIdLoggingContext ( _session . SessionId ) )
190
135
{
191
136
try
@@ -199,14 +144,14 @@ void IEnlistmentNotification.Rollback(Enlistment enlistment)
199
144
}
200
145
finally
201
146
{
202
- _session = null ;
203
147
enlistment . Done ( ) ;
204
148
}
205
149
}
206
150
}
207
151
208
152
void IEnlistmentNotification . InDoubt ( Enlistment enlistment )
209
153
{
154
+ using ( this )
210
155
using ( new SessionIdLoggingContext ( _session . SessionId ) )
211
156
{
212
157
try
@@ -220,12 +165,21 @@ void IEnlistmentNotification.InDoubt(Enlistment enlistment)
220
165
}
221
166
finally
222
167
{
223
- _session = null ;
224
168
enlistment . Done ( ) ;
225
169
}
226
170
}
227
171
}
228
172
173
+ public void Dispose ( )
174
+ {
175
+ if ( ! ReferenceEquals ( _transaction , null ) )
176
+ _transaction . Dispose ( ) ;
177
+ _transaction = null ;
178
+ if ( ! ReferenceEquals ( _session , null ) )
179
+ _session . TransactionContext = null ;
180
+ _session = null ;
181
+ }
182
+
229
183
void OnTransactionCompleted ( bool successful )
230
184
{
231
185
var transactionContext = _session . TransactionContext ;
0 commit comments