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

[CHANGE] [JS] [CONSUMERS] fetch()/next() can fail on consumer/stream errors #667

Merged
merged 7 commits into from
Mar 22, 2024

Conversation

aricart
Copy link
Member

@aricart aricart commented Mar 21, 2024

This change modifies the behavior of fetch() and next() to react to consumer deleted / consumer not found / stream not found server responses. Since these operations have a termination condition (the end of the next() or fetch()), such events are appropriate.

Ordered consumers work similarly with next() and fetch() as described above. Applications that use next()/fetch() should trap errors, and re-attempt as desired.

consume() API however will keep reporting via its status() if there's an error related to the stream or consumer. Clients that want to stop processing during a consume on consumer deleted/stream not found type errors should setup a listener and then call stop() on the consumer if those conditions are reported and the desired behavior is to stop processing. If the problem resource becomes available, consume() will resume. This is the existing behavior.

This PR also adds the abort_on_missing_resource to consume() options. If a resource such as a stream is not found or consumer is deleted or not found consume() will abort. Note that for ordered consumers will not honor the option if a consumer is not found, as order consumer recreates a consumer on the fly. However deleting an active ordered consumer or its stream will stop it if the option is provided.

… to react to consumer deleted / not found server responses. Since these operations have a termination condition, such events are appropriate. Consume however will keep reporting if there's an error related to the stream or consumer. Clients that want to stop processing during a consume on consumer deleted/stream not found type errors should setup a listener and then call stop on the consumer if those conditions are reported. Order consumers work similarly in next() and fetch() as described above with the exception that consumer not found, really will attempt to recover (as ordered consumers recreate the consumer when there's an error). Applications that use next()/fetch() should trap errors, and re-attempt as desired.
…rce` to consume which will bail a consume if a resource such as a stream/consumer is not found or deleted. By default, `consume()` will attempt to recover.
@Jarema
Copy link
Member

Jarema commented Mar 22, 2024

For the ordered consumer, when abort_on_missing_resource is used, will it also abort i case of server restart (which causes the consumer to go away)?

Copy link

@mtmk mtmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aricart
Copy link
Member Author

aricart commented Mar 22, 2024

For the ordered consumer, when abort_on_missing_resource is used, will it also abort i case of server restart (which causes the consumer to go away)?

No, because consumer not found on ordered consumer will recreate.

Note that for ordered consumers will not honor the option if a consumer is not found, as order consumer recreates a consumer on the fly. However deleting an active ordered consumer or its stream will stop it if the option is provided.

@aricart aricart merged commit d3ab912 into main Mar 22, 2024
3 checks passed
@aricart aricart deleted the consumer-deleted branch March 22, 2024 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants