Skip to content

Commit

Permalink
Merge pull request #82 from reillywatson/master
Browse files Browse the repository at this point in the history
Don't fail to publish subsequent messages after sending one that's too big
  • Loading branch information
kozlovic committed Oct 16, 2015
2 parents 3d9fd81 + 7a46f03 commit ac3cb51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -1208,10 +1208,8 @@ func (nc *Conn) publish(subj, reply string, data []byte) error {
var msgSize int64
msgSize = int64(len(data))
if msgSize > nc.info.MaxPayload {
nc.err = ErrMaxPayload
err := nc.err
nc.mu.Unlock()
return err
return ErrMaxPayload
}

if nc.isClosed() {
Expand Down
4 changes: 4 additions & 0 deletions test/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,8 @@ func TestErrOnMaxPayloadLimit(t *testing.T) {
if err != nats.ErrMaxPayload {
t.Fatalf("Expected to fail trying to send more than max payload, got: %s", err)
}
err = nc.Publish("hello", []byte("a"))
if err != nil {
t.Fatalf("Expected to succeed trying to send less than max payload, got: %s", err)
}
}

0 comments on commit ac3cb51

Please sign in to comment.