Git Product home page Git Product logo

Comments (5)

LucaWolf avatar LucaWolf commented on May 24, 2024 2

I did a quick test and indeed these type of errors 12 are not propagated from the amqp base library; there is nothing any wrapping library can do for you (well, short of checking things, which you could also do in app layer beforehand 3).

The fairly clean way out 4 is to call PublishWithDeferredConfirmWithContext() and then wait on the returned PublisherConfirmation (array of type amqp.DeferredConfirmation) via various tests (array length, [0] is valid then amqp calls on [0] with context and/or timers, whatever the amqp library offers, ref. amqp.DeferredConfirmation See also the publisher_confirm example.

I hope this helped a bit.

Footnotes

  1. publishing on existing exchange but non existing queue does not return any error nor drops/reconnects the channel.

  2. publishing on inaccessible exchange/queues (non existing or ownership) will not return any amqp publishing errors but will drop & reconnect the channel. Publishing WithImmediate will also drop/recover the supporting amqp channel (I wasn't expecting this 🤕 : Exception (540) Reason: "NOT_IMPLEMENTED - immediate=true")

  3. a bit of a shame this library does not export the inner channel manager or up-streams the chan manager safe_wrappers to the consumer/publisher objects. This way the apps could have called on all amqp channel functions, including testing for queues via QueueDeclarePassiveSafe

  4. looks like you're better off awaiting confirmations from the app layer as described above.

from go-rabbitmq.

wagslane avatar wagslane commented on May 24, 2024

The Publish function does return an error, is there something else I'm missing?

from go-rabbitmq.

gnuletik avatar gnuletik commented on May 24, 2024

Hi, thanks for the feedback!

Yes, the Publish function does return an error in its signature.
However, when Publish fails, the error is not propagated to the caller.

For example, in the scenario if the Publish triggers an ACCESS_REFUSED error.
The error return value is nil.

Then, the logger logs:

channelmanager/channel_manager.go:69: attempting to reconnect to amqp server after close with error: Exception (403) Reason: "ACCESS_REFUSED - write access to exchange '...' in vhost '...' refused for user '...'" 
channelmanager/channel_manager.go:101: waiting 5s seconds to attempt to reconnect to amqp server
channelmanager/channel_manager.go:124: error closing channel while reconnecting: Exception (504) Reason: "channel/connection is not open"
channelmanager/channel_manager.go:71: successfully reconnected to amqp server
publish.go:115: successful publisher recovery from: Exception (403) Reason: "ACCESS_REFUSED - write access to exchange '...' in vhost '...' refused for user '...'" 

This test has been run with github.com/wagslane/[email protected]

When the error is ACCESS_REFUSED, that seems legit to discard the error.
However, I'm trying to implement a retry mechanism when the rabbitmq server is being upgraded / restarted by a cloud provider (e.g. AWS AmazonMQ RabbitMQ).

Thanks!

from go-rabbitmq.

gnuletik avatar gnuletik commented on May 24, 2024

Thanks for investigating into this @LucaWolf !

I'm quite surprised that the underlying library does not propagate 540 exceptions.
I tried to look into the library which exceptions returns an error but could not find it.

I'll use PublishWithDeferredConfirmWithContext to handle this case, thanks!

from go-rabbitmq.

wagslane avatar wagslane commented on May 24, 2024

Glad you found that!

from go-rabbitmq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.