Skip to content

Commit

Permalink
[CHANGED] Remove restriction on AckNone policy for pull consumers (#1090
Browse files Browse the repository at this point in the history
)
  • Loading branch information
piotrpio committed Sep 21, 2022
1 parent 8e72eaa commit 4832b65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 0 additions & 4 deletions js.go
Expand Up @@ -1420,10 +1420,6 @@ func (js *js) subscribe(subj, queue string, cb MsgHandler, ch chan *Msg, isSync,

// Some checks for pull subscribers
if isPullMode {
// Check for bad ack policy
if o.cfg.AckPolicy == AckNonePolicy {
return nil, fmt.Errorf("nats: invalid ack mode for pull consumers: %s", o.cfg.AckPolicy)
}
// No deliver subject should be provided
if o.cfg.DeliverSubject != _EMPTY_ {
return nil, ErrPullSubscribeToPushConsumer
Expand Down
8 changes: 8 additions & 0 deletions test/js_test.go
Expand Up @@ -686,6 +686,14 @@ func TestJetStreamSubscribe(t *testing.T) {
t.Fatalf("Error on subscribe: %v", err)
}
sub.Unsubscribe()

// Pull consumer with AckNone policy
sub, err = js.PullSubscribe("bar", "", nats.AckNone())
if err != nil {
t.Fatalf("Error on subscribe: %v", err)
}
sub.Unsubscribe()

// Can't specify DeliverSubject for pull subscribers
_, err = js.PullSubscribe("bar", "foo", nats.DeliverSubject("baz"))
if err != nats.ErrPullSubscribeToPushConsumer {
Expand Down

0 comments on commit 4832b65

Please sign in to comment.