I know this is very very very basic (I'm not event mocking a Bunny::BasicReturn) but I had the need to test my on_return behaviour when publishing messages with a mandatory: true option.
It works as is but:
Would be better to emulate Bunny's BasicReturn logic (I couldn't figure out how)
Could not find where to add some specs for this
Methods added:
on_return(&block) : public method on Bunny::Exchange (exact same implementation as Bunny)
handle_return(basic_return, properties, content) : private method on Bunny::Exchange
Methods updated:
deliver for Direct, Topic, Fanout (Headers does not work as intended so I haven't changed anything)
If opts[:mandatory] is true then deliver will call handle_return to notify that the message could not be delivered.
Hi 👋
I know this is very very very basic (I'm not event mocking a
Bunny::BasicReturn
) but I had the need to test myon_return
behaviour when publishing messages with amandatory: true
option.It works as is but:
Bunny
'sBasicReturn
logic (I couldn't figure out how)Methods added:
on_return(&block)
: public method onBunny::Exchange
(exact same implementation asBunny
)handle_return(basic_return, properties, content)
: private method onBunny::Exchange
Methods updated:
deliver
forDirect
,Topic
,Fanout
(Headers
does not work as intended so I haven't changed anything)opts[:mandatory]
istrue
thendeliver
will callhandle_return
to notify that the message could not be delivered.