Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHANGED] Remove restriction on AckNone policy for pull consumers #1090

Merged
merged 1 commit into from Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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