Hello Everybody,<div><br></div><div>I developed a monitoring application using Rabbit and Rabbit RPC plugin. I'm monitoring events on my HTML pages and sending messages over HTTP.</div><div>What my javascript does is for each event, it opens a channel, send a message and close that channel. This is the snippet:</div>
<div><br></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-tab-span" style="white-space:pre">                        </span>function on_open(channel) {</blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-tab-span" style="white-space:pre">                                </span>channel.queueDeclare(exchangeQueue, false, true, false, false)</blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-tab-span" style="white-space:pre">                        </span> .addCallback( function() {</blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-tab-span" style="white-space:pre">                                        </span>channel.basicPublish("", exchangeQueue, exchangeMessage, props);</blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-tab-span" style="white-space:pre">                                        </span>channel.close();</blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-tab-span" style="white-space:pre">                                </span>});</blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-tab-span" style="white-space:pre">                </span> <span class="Apple-tab-span" style="white-space:pre">        </span>}</blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<br></blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-tab-span" style="white-space:pre">                </span> <span class="Apple-tab-span" style="white-space:pre">        </span>function trackEvent(queue, jsonMsg){</blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-tab-span" style="white-space:pre">                                </span>channel = RabbitMQ.openChannel(on_open, {'exchangeQueue': queue, 'exchangeMessage': jsonMsg});</blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<span class="Apple-tab-span" style="white-space:pre">                </span> <span class="Apple-tab-span" style="white-space:pre">        </span>}<span class="Apple-tab-span" style="white-space:pre">        </span></blockquote></blockquote><div><br>
</div><div><br></div><div>When I saw the examples I was wondering what is the best practice using channel in a browser?</div><div>Should I open and close it for each message or should I leave it open and send messages <span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; white-space: nowrap; background-color: rgb(255, 255, 255); ">through this channel?</span></div>
<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; white-space: nowrap; background-color: rgb(255, 255, 255); "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; white-space: nowrap; background-color: rgb(255, 255, 255); ">Thank you!</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="white-space: nowrap;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="white-space: nowrap;">Cheers,</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="white-space: nowrap;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="white-space: nowrap;">Bruno Carneiro</span></font></div>