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

Question about SetLogHandler and SetErrorHandler #2178

Open
kfrn opened this issue Jan 25, 2024 · 0 comments
Open

Question about SetLogHandler and SetErrorHandler #2178

kfrn opened this issue Jan 25, 2024 · 0 comments

Comments

@kfrn
Copy link

kfrn commented Jan 25, 2024

I'm looking for some clarity about these two ConsumerBuilder methods.

Here's the current signature and documentation comment for SetLogHandler():

public ConsumerBuilder<TKey,TValue> SetLogHandler(Action<IConsumer<TKey,TValue>,LogMessage> logHandler)
in class ConsumerBuilder<TKey,TValue>

TKey is Ignore
TValue is string 

Set the handler to call when there is information available to be logged. If not specified, a default callback that writes to stderr will be used.
Remarks: By default not many log messages are generated. For more verbose logging, specify one or more debug contexts using the 'Debug' configuration property. Warning: Log handlers are called spontaneously from internal librdkafka threads and the application must not call any Confluent.Kafka APIs from within a log handler or perform any prolonged operations.
Exceptions: Any exception thrown by your log handler will be silently ignored.

I'm interested in the part in bold. The first parameter to the callback is IConsumer. So you have access to the consumer within the callback... but you're not supposed to call anything on it/use any of its APIs? I want to check if I'm understanding correctly.

SetErrorHandler():

public ConsumerBuilder<TKey,TValue> SetErrorHandler(Action<IConsumer<TKey,TValue>,Error> errorHandler)
in class ConsumerBuilder<TKey,TValue>

TKey is Ignore
TValue is string 

Set the handler to call on error events e.g. connection failures or all brokers down. Note that the client will try to automatically recover from errors that are not marked as fatal. Non-fatal errors should be interpreted as informational rather than catastrophic.
Remarks: Executes as a side-effect of the Consume method (on the same thread).
Exceptions: Any exception thrown by your error handler will be silently ignored.

Does the same restriction about not using Confluent.Kafka APIs apply for SetErrorHandler()?

Thank you very much 🙏

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

No branches or pull requests

1 participant