Several queues issue

42 views
Skip to first unread message

DOBRO

unread,
Feb 15, 2011, 8:27:11 AM2/15/11
to amqp-js
Hi,

I ran into the issue of binding several queues to different exchanges.
Let me explain what I mean.

In this example we
- declare two exchanges
- declare two queues
- bind each queue to its exchange (queue 1 to ex1, queue2 to ex2)

-------------------------------------------------------------------------------------------------------------------------------------
var ex1 = 'ex.fanout';
var ex2 = 'ex.direct';

var queue1 = 'q1';
var queue2 = 'q2';


MQ.exchange(ex1, {type: 'fanout', autoDelete: true});
MQ.exchange(ex2, {type: 'direct', autoDelete: true});
MQ.queue(queue1, {autoDelete: true, durable: false, exclusive:
true}).bind(ex1, 'all');
MQ.queue(queue2, {autoDelete: true, durable: false, exclusive:
true}).bind(ex2, 'qqq');
-------------------------------------------------------------------------------------------------------------------------------------

The issue is that Firebug shows that all the queues have been bound to
all exchanges, that is Javascript API creates additional binding for
each queue per exchange even if we don't call "bind" for the exchange.

We can also check it by running the script:

---------------------------------------------------------------------------------
var a = [queue1,queue2];
for (var i in a) {
var q = a[i];
for (var ex in MQ.queues[q].bindings) {
alert(q + ' -> ' + ex)
}
}
---------------------------------------------------------------------------------

I'm trying to figure out which part of code in mq.js creates extra
bindings but I don't understand, yet.

Any ideas?

Thanks.

Dan Simpson

unread,
Feb 15, 2011, 11:35:42 AM2/15/11
to amq...@googlegroups.com
Dobro,

You are now a contributor so you can make commits to the code base as you desire.  If you are more comfortable issuing pull requests, thats fine.

I think I may have fixed the issue.  The JS code has some confusing aspects, and the "bindings" object seemed to be shared by all queues.  I moved the declaration to the constructor.

Also, in regards to your pull request, I merged your changes, but I am going to allow you to change one thing.  Most of my methods are camelCase with verbNoun as their form, such as createQueue or createExchange.  It would be nice to keep that pattern consistent for queue_delete, and make it deleteQueue.

I may give the JS code a make-over if I find some time.

--Dan


--
You received this message because you are subscribed to the Google Groups "amqp-js" group.
To post to this group, send email to amq...@googlegroups.com.
To unsubscribe from this group, send email to amqp-js+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/amqp-js?hl=en.


DOBRO

unread,
Feb 16, 2011, 8:13:41 AM2/16/11
to amqp-js
Dan,

I've sent a pull request at github with appropriate changes.

BTW, new property onReceiveHandler is added for MQ. It makes the code
to run faster because setting MQ.onReceiveHandler = "queue", we don't
need to check routing key patterns and no cycles are needed around the
bindings. We just need to add callback function for a queue.

MQ.onReceiveHandler is set to "binding" by default and repeats
previous behaviuor.

Thanks.

On 15 фев, 19:35, Dan Simpson <dan.simp...@gmail.com> wrote:
> Dobro,
>
> You are now a contributor so you can make commits to the code base as you
> desire.  If you are more comfortable issuing pull requests, thats fine.
>
> I think I may have fixed the issue.  The JS code has some confusing aspects,
> and the "bindings" object seemed to be shared by all queues.  I moved the
> declaration to the constructor.
>
> Also, in regards to your pull request, I merged your changes, but I am going
> to allow you to change one thing.  Most of my methods are camelCase with
> verbNoun as their form, such as createQueue or createExchange.  It would be
> nice to keep that pattern consistent for queue_delete, and make it
> deleteQueue.
>
> I may give the JS code a make-over if I find some time.
>
> --Dan
>
Reply all
Reply to author
Forward
0 new messages