[rabbitmq-discuss] Load balancing exchange

Petr Sturc petr.sturc at gmail.com
Mon Aug 18 18:06:35 BST 2008


Hi,

I would like to implement kind of "true load balancing" between
consumers. The idea is to implement a new type of exchange,
which routes a message to the shortest queue among all queues bound to
it with the correct routing key.

Implementation of a new exchange type seems to be quite easy - I am
just adding two new methods to rabbit_exchange.erl
- check_type(<<"loadbalance">>)  and  route(#exchange{name = Name,
type = loadbalance}, RoutingKey). But the problem I have
is the "shortest queue". I am trying following (in the route function)
in order to get queue length

 {ok,_,QLen,_} = rabbit_amqqueue:stat( #amqqueue{pid = QPid}

, but QLen is always zero for all bound queues.

Any idea what I am doing wrong?

Regards,
Petr




More information about the rabbitmq-discuss mailing list