apache / pulsar-dotpulsar

The official .NET client library for Apache Pulsar

Home Page:https://pulsar.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Producer trying to send message for an indefinite amount of time

christian-ledesma opened this issue · comments

Hi guys, this is really a question
The thing is, everytime my producer is unable to reach a pulsar instance, Send() takes forever and never throws an exception. Is there anyway I can handle this situation or change this behaviour?

We're currently using version 3.1.1

Hi @christian-ledesma ,

Thank you for your question. While you didn't provide a code snippet, I'll make some assumptions based on your context.

If you're using Send without a cancellation token, and it fails to connect, your application will wait indefinitely. To avoid this, consider creating a token that cancels after a specified time span.

For handling state changes, refer to the wiki on monitoring in Pulsar.

If you're interested in specific exceptions, explore the Resilience section in the wiki.

I hope this helps! Let me know if you have any further questions.

Hi @christian-ledesma

Just to add to David's answer: If the producer can't connect, then as long as the Producer is not Faulted it will try to reconnect, meaning that your Send operation will continue. The Send operation will only throw an exception if the cancellation token you provide times out or the producer is faulted.