Skip to content

Commit

Permalink
Merge pull request #641 from nats-io/consumer-deleted
Browse files Browse the repository at this point in the history
prevent consumer deleted from stopping iterator
  • Loading branch information
aricart committed Dec 1, 2023
2 parents 6fcf406 + a8e7f35 commit 37f5bd6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions jetstream/consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ export enum ConsumerEvents {
*/
ConsumerNotFound = "consumer_not_found",

/**
* Notification that the consumer was deleted. This notification
* means the consumer will not get messages unless it is recreated. The client
* will continue to attempt to pull messages. Ordered consumer will recreate it.
*/
ConsumerDeleted = "consumer_deleted",

/**
* This notification is specific of ordered consumers and will be notified whenever
* the consumer is recreated. The argument is the name of the newly created consumer.
Expand Down Expand Up @@ -358,8 +365,10 @@ export class PullConsumerMessagesImpl extends QueuedIteratorImpl<JsMsg>
this.stop(error);
});
} else if (code === 409 && description === "consumer deleted") {
const error = toErr();
this.stop(error);
this.notify(
ConsumerEvents.ConsumerDeleted,
`${code} ${description}`,
);
} else {
this.notify(
ConsumerDebugEvents.DebugEvent,
Expand Down

0 comments on commit 37f5bd6

Please sign in to comment.