Comments (5)
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
-
publishing on existing exchange but non existing queue does not return any error nor drops/reconnects the channel. ↩
-
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") ↩ -
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
↩ -
looks like you're better off awaiting confirmations from the app layer as described above. ↩
from go-rabbitmq.
The Publish function does return an error, is there something else I'm missing?
from go-rabbitmq.
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.
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.
Glad you found that!
from go-rabbitmq.
Related Issues (20)
- get message in a variable like github.com/streadway/amqp HOT 2
- error on ack HOT 1
- Direct reply-to HOT 2
- rabbitmq-manager no consumers HOT 2
- only reconnecting some consumers HOT 1
- Shutdown after a fixed number of reconnection attempts HOT 2
- Support for Dead Letter Exchange HOT 1
- Cluster support HOT 1
- Declare queue without consuming messages HOT 2
- My business requires batch processing of messages. Currently, the Consumer can only provide one callback at a time. Can I open up chan (msgs)? I want to handle message callbacks myself HOT 1
- received 'direct' but current is 'topic'" HOT 1
- A queue can accept multiple bindings from multiple exchanges HOT 1
- Support for RabbitMQ Clusters HOT 3
- memory leak HOT 12
- how to gracefully shutdown mq consumers?
- Docs specify `WithPublisherOptionsExchangeDeclare` *stops* this library from declaring the exchanges existance
- Asynchronous reconnection
- NotifyPublish ReconnectCount - how is it intended to be used? HOT 1
- reconnection bug
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-rabbitmq.