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

Improve reconnection #336

Open
4 of 6 tasks
Gsantomaggio opened this issue Dec 15, 2023 · 0 comments
Open
4 of 6 tasks

Improve reconnection #336

Gsantomaggio opened this issue Dec 15, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Gsantomaggio
Copy link
Member

Gsantomaggio commented Dec 15, 2023

Is your feature request related to a problem? Please describe.

The Producer and Consumer classes provide a way to auto-reconnect, but there is some edge case not correctly handled like:

The auto-reconnection is hidden from the user. It is hard to understand the status without logs.

Describe the solution you'd like

What to do:

RabbitMQ.Stream.Client.Reliable.Producer[0] Error sending message. Most likely the message is not sent to the stream: BenchmarkDotNet2.Message wont' receive confirmation so you will receive a timeout error System.Threading.Tasks.TaskCanceledException: A task was canceled.    at RabbitMQ.Stream.Client.RawProducer.SemaphoreAwaitAsync() in rabbitmq/rabbitmq-stream-dotnet-client/RabbitMQ.Stream.Client/RawProducer.cs:line 231    at RabbitMQ.Stream.Client.RawProducer.Send(UInt64 publishingId, Message message) in /Users/gas/git/rabbitmq/rabbitmq-stream-dotnet-client/RabbitMQ.Stream.Client/RawProducer.cs:line 340    at RabbitMQ.Stream.Client.Reliable.Producer.SendInternal(UInt64 publishingId, Message message) in rabbitmq-stream-dotnet-client/RabbitMQ.Stream.Client/Reliable/Producer.cs:line 271
  • Handle super Stream error like:
RabbitMQ.Stream.Client.Reliable.Producer[0] Error sending message. Most likely the message is not sent to the stream: invoices.Message wont' receive confirmation so you will receive a timeout error System.DivideByZeroException: Attempted to divide by zero. 

Describe alternatives you've considered

No response

Additional context

No response

@Gsantomaggio Gsantomaggio added the enhancement New feature or request label Dec 15, 2023
Gsantomaggio added a commit that referenced this issue Dec 19, 2023
The pr is part of #336
the aim is to standardise the behaviour.

- Add AlreadyClosedException when a producer or super stream producer is closed
  In the same way like AMQP does with channels

- Producer: Flush the pending messages when closed.
- Producer: Add AlreadyClosedException when closed. So it is the same like:
  AMQP and RawProducer and RawSuperStreamProducer

- Improve IsAKnownException function with the AggregateException that can contains
  known exceptions needed for reconnect the client

- Add EntitiesStateTests to test all the status and verify that all the entities have the
  same behaviour

Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Gsantomaggio added a commit that referenced this issue Dec 20, 2023
* Improve the rawProducer and rawSuperStreamProducer status

*   Part of #336
     the aim is to standardise the behaviour.

*  Add AlreadyClosedException when a producer or super stream producer is closed
  In the same way as AMQP does with channels

*  Producer: Flush the pending messages when closed.
* Producer: Add AlreadyClosedException when closed. So it is the same as:
  AMQP and RawProducer and RawSuperStreamProducer

* Improve IsAKnownException function with the AggregateException that can contain
  known exceptions needed to reconnect the client

* Add EntitiesStateTests to test all the status and verify that all the entities have the
  same behaviour

* Assert the AlreadyClosedException Exception

---------
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Gsantomaggio added a commit that referenced this issue Jan 9, 2024
* Part of #336

* Improve the disconnection message.
  It is possible to understand if it is a normal disconnection or an unexpected.
* Remove the Active Items from the connection pool and use the
  Publishers and Consumers client list directly to check the pool size
* Refactor the Factory Classes.
  Remove code duplication in case of metadata update and connection closed. See ReliableBase.OnEntityClosed
* Handle streamNotAvailable error.
  In this case the client will try to reconnect the entity
* Fix the events attach to the RawConsumer and RawProducer.
  The events are attached only if the ResponseCode is OK
* Detach the events once the entity receives the disconnection or metadata update.
  In that case, the entity is closed
* Introduce ReliableEntityStatus like a state machine to understand the status of Producer and Consumer classes
* Add ResourceAvailableReconnectStrategy interface to Handle the retry in case testing in a stream exists.
  See ReliableBase CheckIfStreamIsAvailable
* Change the  MetadataHandler to Func<MetaDataUpdate, Task> to be like the other methods
* Producer and Consumer classes fail fast during the first initialization.
  The user is aware of what is happening. The reconnect part occurs only after the first boot.

Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Gsantomaggio added a commit that referenced this issue Jan 11, 2024
* Improve Reconnection

* Part of #336

* Improve the disconnection message.
  It is possible to understand if it is a normal disconnection or an unexpected.
* Remove the Active Items from the connection pool and use the
  Publishers and Consumers client list directly to check the pool size
* Refactor the Factory Classes.
  Remove code duplication in case of metadata update and connection closed. See ReliableBase.OnEntityClosed
* Handle streamNotAvailable error.
  In this case the client will try to reconnect the entity
* Fix the events attach to the RawConsumer and RawProducer.
  The events are attached only if the ResponseCode is OK
* Detach the events once the entity receives the disconnection or metadata update.
  In that case, the entity is closed
* Introduce ReliableEntityStatus like a state machine to understand the status of Producer and Consumer classes
* Add ResourceAvailableReconnectStrategy interface to Handle the retry in case testing in a stream exists.
  See ReliableBase CheckIfStreamIsAvailable
* Change the  MetadataHandler to Func<MetaDataUpdate, Task> to be like the other methods
* Producer and Consumer classes fail fast during the first initialization.
  The user is aware of what is happening. The reconnect part occurs only after the first boot.
---------
Signed-off-by: Gabriele Santomaggio <G.santomaggio@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant