-
-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Hello!
I've identified a problem in my application where when I try to dispose disconnected producers my thread will block forever.
Whenever I attempt to publish a message I first lazy load a producer. I have code that looks something like:
// Is the existing producer good?
if (await producer.IsConnected())
return producer;
// Dispose the dead producer
await producer.DisposeAsync();
// Create a new producer
return await CreateProducerAsync();
I'm running the official Pulsar Docker image and successfully publishing messages to it. If I restart the container, breaking the connection, my application will hit the DisposeAsync() and block forever.
Looking at the dispose method for ProducerImpl it looks like it doesn't really do anything if the connection state is closed. https://github.com/fsprojects/pulsar-client-dotnet/blob/develop/src/Pulsar.Client/Internal/ProducerImpl.fs#L935
As a workaround I'm simply not disposing my producers if they're no longer connected anymore. Is this safe?