Skip to content

Commit

Permalink
[FIX] changed consumer so that a server consumer_deleted notification…
Browse files Browse the repository at this point in the history
… doesn't stop the iterator. The consumer will notify the condition, and continue to re-attempt to retrieve messages.
  • Loading branch information
aricart committed Dec 1, 2023
1 parent 6fcf406 commit a8e7f35
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 a8e7f35

Please sign in to comment.