[rabbitmq-discuss] immediate, mandatory flag with no consumers
Emile Joubert
emile at rabbitmq.com
Tue May 8 12:16:11 BST 2012
Hi,
On 08/05/12 02:33, Unni, Monish wrote:
> we also found for rabbitmq, we could use "alternate-exchange"
> (extension), since, we are mostly calling services that are built
> in-house. this seems to be a very generic way to handle
> "non-routable" calls. the restriction seems to be this exchange
> cannot be built on "amq.direct" as an "alternate-exchange" needs to
> be specified at the time of creation - is this right?
You can specify an alternate exchange for any exchange type, not only
direct exchanges. The alternate exchange must be named at declaration
time of the exchange making use of it.
> for "no-consumers" i am not sure if we have any "broker" level
> setting except using "dead-letter-messages" as given :
> http://www.rabbitmq.com/extensions.html#dead-letter-messages [also,
> we are loosely-coupled, i.e we really don't want "transaction-level"
> broker semantics, so "confirmation" is not an option...]
If a message is successfully routed to a queue then dead letter handling
will not come into effect, because the message wasn't dropped.
One way to handle the "no-consumers" scenario is to allow consumers to
declare their own queues and bindings. You can then make use of
alternate exchanges (or the mandatory publication flag) to handle
unroutable messages. In this case the presence of consumers and routes
should correspond. This solution won't work if messages must be
delivered only to a single consumer.
Another option is to let a shared queue expire when the last consumer
unsubscribes. Messages destined for such a queue will become unroutable
when the last consumer leaves. This can then be handled with alternate
exchanges (or the mandatory flag). Consumers should declare the shared
queue before subscribing, in case there were no other subscribers.
(See queue leases: http://www.rabbitmq.com/extensions.html#lifetimes)
If your client supports the immediate publication flag then that could
also be used.
-Emile
More information about the rabbitmq-discuss
mailing list