reliable

command
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2025 License: MIT Imports: 16 Imported by: 0

README

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 re-send in an option that can be enabled by setting enableResend to true.

The example enables golang pprof you can check the url: localhost:6060/debug/pprof/.
The scope is to check the resources used by the application in case of reconnection.

The reliable_common.go/retry function does different checks because during the restart broker can happen different events, please check:

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL