-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the reliable consumer (#271)
* Implement the reliable consumer * Add tests for the reliable consumer * Add the documentation for the `ha` package --------- Signed-off-by: Gabriele Santomaggio <[email protected]>
- Loading branch information
1 parent
1b75cdb
commit 80cdcd5
Showing
14 changed files
with
664 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
Stream examples | ||
=== | ||
|
||
- [Getting started](./getting_started.go). A good point to start. | ||
- [Offset Start](./offsetStart/offset.go). How to set different points to start consuming | ||
- [Offset Tracking](./offsetTracking/offsetTracking.go). Manually store the consumer offset | ||
- [Automatic Offset Tracking](./automaticOffsetTracking/automaticOffsetTracking.go). Automatic store the consumer offset | ||
- [Getting started TLS](./tls/getting_started_tls.go). A TLS example. ( you can run `make rabbitmq-server-tls` to create a tls single rabbitmq node ) | ||
- [HA Producer](./haProducer/producer.go). HA producer example (Still experimental) | ||
- [Deduplication](./deduplication/deduplication.go). deduplication example, run it more than one time, and the records <br /> | ||
- [Getting started](./getting_started.go) - A good point to start. | ||
- [Offset Start](./offsetStart/offset.go) - How to set different points to start consuming | ||
- [Offset Tracking](./offsetTracking/offsetTracking.go) - Manually store the consumer offset | ||
- [Automatic Offset Tracking](./automaticOffsetTracking/automaticOffsetTracking.go) - Automatic store the consumer offset | ||
- [Getting started TLS](./tls/getting_started_tls.go) - A TLS example. ( you can run `make rabbitmq-server-tls` to create a tls single rabbitmq node ) | ||
- [Deduplication](./deduplication/deduplication.go) - Deduplication example, run it more than one time, and the records <br /> | ||
won't change, since the server will handle the deduplication. | ||
- [Using a load balancer](./proxy/proxy.go). An example how to use the client with a TLS load balancer.<br /> | ||
- [Using a load balancer](./proxy/proxy.go) - An example how to use the client with a TLS load balancer.<br /> | ||
Use the [RabbitMQ TLS cluster](../compose) to run a TLS and no TLS cluster. <br /> | ||
For more details: https://blog.rabbitmq.com/posts/2021/07/connecting-to-streams/ | ||
- [Sub Entries Batching](./sub-entries-batching/sub_entries_batching.go). Sub Entries Batching example | ||
- [Sub Entries Batching](./sub-entries-batching/sub_entries_batching.go) - Sub Entries Batching example | ||
|
||
- [Reliable](./reliable) - Reliable Producer and Reliable Consumer example | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
### Reliable Producer/Consumer example | ||
|
||
This example demonstrates how to use reliable producers and consumers to send and receive messages. | ||
The `ReliableProducer` and `ReliableConsumer` are in the `ha` package and use the disconnection event to reconnect to the broker. | ||
You can write your own `ReliableProducer` and `ReliableConsumer` by using the `Close` channel. | ||
|
||
The `ReliableProducer` blocks the sending of messages when the broker is disconnected and resumes sending when the broker is reconnected. | ||
|
||
In this example, we use `unConfirmedMessages` to re-send the messages that were not confirmed by the broker, for instance, in case of a disconnection. | ||
Then, the `unConfirmedMessages` are sent to the broker again. | ||
Note: | ||
- The `unConfirmedMessages` are not persisted, so if the application is restarted, the `unConfirmedMessages` will be lost. | ||
- The `unConfirmedMessages` order is not guaranteed | ||
- The `unConfirmedMessages` can grow indefinitely if the broker is unavailable for a long time. | ||
|
||
|
||
The `reliable_common.go/retry` function does different checks because during the restart broker can happen different events, please check: | ||
- [this presentation](https://docs.google.com/presentation/d/111PccBLRGb-RNpYEKeIm2MQvdky-fXrQ/edit?usp=sharing&ouid=106772747306273309885&rtpof=true&sd=true) for more details. | ||
- [the code](../../pkg/ha/reliable_common.go) for the implementation details. | ||
|
Oops, something went wrong.