Closed Gsantomaggio closed 10 months ago
Attention: 42 lines
in your changes are missing coverage. Please review.
Comparison is base (
7fa33dd
) 91.84% compared to head (8e8dc04
) 91.80%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Fixes: https://github.com/rabbitmq/rabbitmq-stream-dotnet-client/discussions/333 Fixes: https://github.com/rabbitmq/rabbitmq-stream-dotnet-client/issues/335
Preface
The PR is focused on making the client more stable during the server restart and better handling the metadata update event.
Most of the changes are in the super stream producer and consumer. See the issue https://github.com/rabbitmq/rabbitmq-stream-dotnet-client/discussions/333
1- What's changed in the super stream part
The RawSuperStreamProducer and RawSuperStreamConsumer expose two callbacks:
ConnectionClosedHandler (reason, stream)
MetadataHandler(update)
ISuperStreamProducer
andISuperStreamConsumer
interfacesConnectionClosedHandler
The callback is raised each time a partition is closed for some reason. You can check the reason with:
1- The super stream partition is closed by the
Close()
method, so there are no problems. It can be helpful in terms of alerting or logs.2- The super stream partition is closed in an unexpected way like kill the connection, network problems broker restart etc..
In that case, you can reconnect the partition with the
ReconnectPartition
method. Like:MetadataHandler
It happens when there is a change in the stream topology. See the document for more details.
In this case, the server drops all the producers and consumers. So, you need to react to the Metadata Handler event. You can decide to reconnect the producer and consumer using the
ReconnectPartition
Producer and Consumer classes
The
Producer
andConsumer
classes handle automatically theConnectionClosedHandler
and theMetadataHandler
events for stream and super stream.2- Fail fast
The Producer and Consumer classes can restore the connection automatically when they are up and running. The classes will fail immediately if there are problems during the first connection. This behaviour is now like the Java Client's.
3- Survive a cluster restart
Please follow this presentation to understand what happens during a cluster restart
You can create your own way to handle the reconnection based on Raw Classes.