Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
wait for disposition on send
Browse files Browse the repository at this point in the history
  • Loading branch information
devigned committed Nov 29, 2018
1 parent 0719d6a commit cf19f3b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ func (r *receiver) Close(ctx context.Context) error {
r.done()
}

err := r.receiver.Close(ctx)
if err != nil {
_ = r.session.Close(ctx)
_ = r.connection.Close()
return err
}

err = r.session.Close(ctx)
if err != nil {
_ = r.connection.Close()
return err
}

return r.connection.Close()
}

Expand Down
16 changes: 15 additions & 1 deletion sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ func (s *sender) Close(ctx context.Context) error {
span, _ := s.startProducerSpanFromContext(ctx, "sb.sender.Close")
defer span.Finish()

err := s.sender.Close(ctx)
if err != nil {
_ = s.session.Close(ctx)
_ = s.connection.Close()
return err
}

err = s.session.Close(ctx)
if err != nil {
_ = s.connection.Close()
return err
}

return s.connection.Close()
}

Expand Down Expand Up @@ -222,7 +235,8 @@ func (s *sender) newSessionAndLink(ctx context.Context) error {

amqpSender, err := amqpSession.NewSender(
amqp.LinkTargetAddress(s.getAddress()),
amqp.LinkSenderSettle(amqp.ModeMixed))
amqp.LinkSenderSettle(amqp.ModeMixed),
amqp.LinkReceiverSettle(amqp.ModeSecond))
if err != nil {
log.For(ctx).Error(err)
return err
Expand Down

0 comments on commit cf19f3b

Please sign in to comment.