Skip to content

Commit 344c73b

Browse files
committed
merge bug19793 into default
2 parents 7e1b1c4 + 52668d1 commit 344c73b

File tree

2 files changed

+83
-14
lines changed

2 files changed

+83
-14
lines changed

src/client/api/IModel.cs

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,55 @@ BasicGetResult BasicGet(string queue,
358358

359359
///<summary>Close this session.</summary>
360360
///<remarks>
361-
/// If the session is already closed (or closing), then this
362-
/// method does nothing but wait for the in-progress close
363-
/// operation to complete. This method will not return to the
364-
/// caller until the shutdown is complete.
361+
///If the session is already closed (or closing), then this
362+
///method does nothing but wait for the in-progress close
363+
///operation to complete. This method will not return to the
364+
///caller until the shutdown is complete.
365+
///</remarks>
366+
[AmqpMethodDoNotImplement(null)]
367+
void Close();
368+
369+
///<summary>Close this session.</summary>
370+
///<remarks>
371+
///The method behaves in the same way as Close(), with the only
372+
///difference that the model is closed with the given model
373+
///close code and message.
374+
///<para>
375+
///The close code (See under "Reply Codes" in the AMQP specification)
376+
///</para>
377+
///<para>
378+
///A message indicating the reason for closing the model
379+
///</para>
365380
///</remarks>
366381
[AmqpMethodDoNotImplement(null)]
367382
void Close(ushort replyCode, string replyText);
383+
384+
///<summary>Abort this session.</summary>
385+
///<remarks>
386+
///If the session is already closed (or closing), then this
387+
///method does nothing but wait for the in-progress close
388+
///operation to complete. This method will not return to the
389+
///caller until the shutdown is complete.
390+
///In comparison to normal Close() method, Abort() will not throw
391+
///AlreadyClosedException or IOException during closing model.
392+
///</remarks>
393+
[AmqpMethodDoNotImplement(null)]
394+
void Abort();
395+
396+
///<summary>Abort this session.</summary>
397+
///<remarks>
398+
///The method behaves in the same way as Abort(), with the only
399+
///difference that the model is closed with the given model
400+
///close code and message.
401+
///<para>
402+
///The close code (See under "Reply Codes" in the AMQP specification)
403+
///</para>
404+
///<para>
405+
///A message indicating the reason for closing the model
406+
///</para>
407+
///</remarks>
408+
[AmqpMethodDoNotImplement(null)]
409+
void Abort(ushort replyCode, string replyText);
368410
}
369411

370412
///<summary>Represents Basic.GetOk responses from the server.</summary>

src/client/impl/ModelBase.cs

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -775,22 +775,49 @@ public abstract void BasicReject(ulong deliveryTag,
775775

776776
void IDisposable.Dispose()
777777
{
778-
Close(200, "");
778+
Close();
779+
}
780+
781+
public void Close()
782+
{
783+
Close(200, "Goodbye");
779784
}
780785

781-
public void Close(ushort replyCode, string replyText)
786+
public void Close(ushort replyCode, string replyText)
787+
{
788+
Close(replyCode, replyText, false);
789+
}
790+
791+
public void Abort()
792+
{
793+
Abort(200, "Goodbye");
794+
}
795+
796+
public void Abort(ushort replyCode, string replyText)
797+
{
798+
Close(replyCode, replyText, true);
799+
}
800+
801+
public void Close(ushort replyCode, string replyText, bool abort)
782802
{
783803
ShutdownContinuation k = new ShutdownContinuation();
784804
ModelShutdown += new ModelShutdownEventHandler(k.OnShutdown);
785-
786-
if (SetCloseReason(new ShutdownEventArgs(ShutdownInitiator.Application,
787-
replyCode,
788-
replyText)))
789-
{
790-
_Private_ChannelClose(replyCode, replyText, 0, 0);
805+
806+
try {
807+
if (SetCloseReason(new ShutdownEventArgs(ShutdownInitiator.Application,
808+
replyCode,
809+
replyText)))
810+
{
811+
_Private_ChannelClose(replyCode, replyText, 0, 0);
812+
}
813+
k.Wait();
814+
} catch (AlreadyClosedException ace) {
815+
if (!abort)
816+
throw ace;
817+
} catch (IOException ioe) {
818+
if (!abort)
819+
throw ioe;
791820
}
792-
793-
k.Wait();
794821
}
795822

796823
public void HandleChannelCloseOk()

0 commit comments

Comments
 (0)