Skip to content

Commit

Permalink
handle AMQP server shutdown in protocol's receiver (#750)
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Kulyk <[email protected]>

Co-authored-by: Scott Nichols <[email protected]>
  • Loading branch information
oleg-kulyk and n3wscott authored Dec 27, 2021
1 parent 6356512 commit 7772a06
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions protocol/amqp/v2/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ package amqp
import (
"context"
"io"
"strings"

"github.com/Azure/go-amqp"

"github.com/cloudevents/sdk-go/v2/binding"
"github.com/cloudevents/sdk-go/v2/protocol"
)

const serverDown = "session ended by server"

// receiver wraps an amqp.Receiver as a binding.Receiver
type receiver struct{ amqp *amqp.Receiver }

Expand All @@ -24,6 +27,10 @@ func (r *receiver) Receive(ctx context.Context) (binding.Message, error) {
if err == ctx.Err() {
return nil, io.EOF
}
// handle case when server goes down
if strings.HasPrefix(err.Error(), serverDown) {
return nil, io.EOF
}
return nil, err
}

Expand Down

0 comments on commit 7772a06

Please sign in to comment.