Opening 2 channels

40 views
Skip to first unread message

DOBRO

unread,
Jan 28, 2011, 3:30:01 AM1/28/11
to amqp-js
Hi Dan,
I've found out that amqp-js opens two channels when it is connected to
RabbitMQ.
Firebug shows it:

--- Begin ConnectionOpenOk ---
knownHosts = ;
---- End ConnectionOpenOk ----
Ready
--- Begin ChannelOpen ---
outOfBand = ;
---- End ChannelOpen ----
--- Begin ChannelOpen ---
outOfBand = ;
---- End ChannelOpen ----

... and "rabbitmqctl list_channels number" shows that the channels 1
and 2 are open per each browser window.

Is it expected behaviour?

According to RabbitMQ documentation ( http://www.rabbitmq.com/api-guide.html#channel-threads
)
-----------------------------------------------
" Channel thread-safety.

In general, Channel instances should not be used by more than one
thread simultaneously: application code should maintain a clear notion
of thread ownership for Channel instances. If more than one thread
needs to access a particular Channel instance, the application should
enforce mutual exclusion itself, for example by synchronising on the
Channel.

Symptoms of incorrect serialisation of Channel operations include, but
are not limited to, IllegalStateExceptions with the message "cannot
execute more than one synchronous AMQP command at a time", and
UnexpectedFrameErrors."
-----------------------------------------------

BTW, I've run into the issue of losing messages which are published by
several clients simultaneously.
I suppose that it is due the bottleneck in one channel.

So, I suggest a new scheme. It would be great if we could specify this
number by setting underlying property in MQ.configure().

For example,
MQ.configure({
channel: 51,
...})

As for me, I would set the number of the channel as a random positive
integer within the range 1 - 65535.

Thanks.

Dan Simpson

unread,
Jan 28, 2011, 11:26:39 AM1/28/11
to amq...@googlegroups.com
Hey Dobro,

For each exchange you declare/subscribe to, a channel is created.  I have not been in the code in a long time, but what you are stating is possible form an API perspective.  However, I am unsure if side effects will arise when multiple exchanges/queues are using the same channel.  But to answer your question, it is expected behavior, and I probably implemented per the spec.

--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,
Jan 31, 2011, 10:27:18 AM1/31/11
to amqp-js
In my application every client (browser window) declares 6 exchanges.
As you said "For each exchange you declare/subscribe to, a channel is
created", there should be 6 channels created for these exchanges but
only 2 channels created (1 and 2).


On 28 янв, 19:26, Dan Simpson <dan.simp...@gmail.com> wrote:
> Hey Dobro,
>
> For each exchange you declare/subscribe to, a channel is created.  I have
> not been in the code in a long time, but what you are stating is possible
> form an API perspective.  However, I am unsure if side effects will arise
> when multiple exchanges/queues are using the same channel.  But to answer
> your question, it is expected behavior, and I probably implemented per the
> spec.
>
> --Dan
>
> > amqp-js+u...@googlegroups.com<amqp-js%2Bunsu...@googlegroups.com>
> > .

Dan Simpson

unread,
Jan 31, 2011, 8:54:49 PM1/31/11
to amq...@googlegroups.com
Sorry, it's 1 per queue.

--Dan

To unsubscribe from this group, send email to amqp-js+u...@googlegroups.com.

DOBRO

unread,
Feb 1, 2011, 3:08:18 AM2/1/11
to amqp-js
But there is just one queue declared :)

On 1 фев, 04:54, Dan Simpson <dan.simp...@gmail.com> wrote:
> Sorry, it's 1 per queue.
>
> --Dan
>
> > <amqp-js%2Bunsu...@googlegroups.com<amqp-js%252Buns...@googlegroups.com>

Dan Simpson

unread,
Feb 1, 2011, 12:40:05 PM2/1/11
to amq...@googlegroups.com
Ok, so the number of channels opened should equal n + 1, where n is the number of queues.  The +1 is due to the control channel.  The control channel is used for connection specific handshaking and is kept separate from queue messages.

I hope this helps.  Are you having problems with this approach?

--Dan


To unsubscribe from this group, send email to amqp-js+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages