Skip to content

Commit 8bd43fa

Browse files
authored
Fix receiver transaction scope (#5)
1 parent 2a41ed7 commit 8bd43fa

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/dotNet/ClientLib/CoreClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ protected void CloseConnection()
179179
/// <param name="options">parsed options</param>
180180
protected void ArgumentExceptionHandler(Exception ex, Options options)
181181
{
182+
Console.Error.WriteLine(ex.StackTrace);
182183
Console.Error.WriteLine("Invalid command option: " + ex.Message);
183184
options.PrintHelp();
184185
this.exitCode = ReturnCode.ERROR_ARG;
@@ -191,6 +192,7 @@ protected void ArgumentExceptionHandler(Exception ex, Options options)
191192
/// <param name="options">parsed options</param>
192193
protected void OtherExceptionHandler(Exception ex, Options options)
193194
{
195+
Console.Error.WriteLine(ex.StackTrace);
194196
Console.Error.WriteLine("ERROR: {{'cause': '{0}'}}", ex.Message.ToString());
195197

196198
if (options is SenderOptions || options is ReceiverOptions)

src/dotNet/ClientLib/ReceiverClient.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ private void TransactionReceive(ReceiverLink receiver, ReceiverOptions options)
213213

214214
while (txFlag && (nReceived < options.MsgCount || options.MsgCount == 0) && options.TxSize > 0)
215215
{
216-
using (var txs = new TransactionScope(TransactionScopeOption.RequiresNew))
216+
using (var txs = new TransactionScope(TransactionScopeOption.RequiresNew, TimeSpan.FromMinutes(10)))
217217
{
218218
for (int i = 0; i < options.TxSize; i++)
219219
{
@@ -223,6 +223,9 @@ private void TransactionReceive(ReceiverLink receiver, ReceiverOptions options)
223223
receiver.Accept(message);
224224
Formatter.LogMessage(message, options);
225225
nReceived++;
226+
}else
227+
{
228+
break;
226229
}
227230
}
228231
if (options.TxAction.ToLower() == "commit")
@@ -234,7 +237,7 @@ private void TransactionReceive(ReceiverLink receiver, ReceiverOptions options)
234237
txFlag = false;
235238
}
236239
}
237-
using (var txs = new TransactionScope(TransactionScopeOption.RequiresNew))
240+
using (var txs = new TransactionScope(TransactionScopeOption.RequiresNew, TimeSpan.FromMinutes(10)))
238241
{
239242
while ((message = receiver.Receive(options.Timeout)) != null && (nReceived < options.MsgCount || options.MsgCount == 0))
240243
{

0 commit comments

Comments
 (0)