No subject


Thu Mar 14 15:04:54 GMT 2013


track of when the last time you received data, if this timer expires you
know that your connection to the broker is dead and you need to close the
socket. A second timer is needed to keep track of the last time you sent
data, when this timer expires a heartbeat frame needs to be sent.

The current design of rabbitmq-c single-threaded event-driven, meaning the
library itself doesn't do anything when you're not calling into the
library, and has no thread behind the scenes dealing with these timers. So
lets say you received a message, then spent more than 2 * heartbeat
interval processing the message without calling into rabbitmq-c, the
connection would be closed by the broker.

Using the current single-threaded event-driven model of the library I have
not been able to come up with a good way to implement heartbeating that is
totally internal to the library (it also needs to be cross platform and not
rely on a non-sharable global resource like setitimer()/SIGALARM).

The best way to fully implement heartbeats in rabbitmq-c is to add a thread
behind the scenes that deals with these timers, a second alternative that
could be provided by those who don't want the overhead of a separate
behind-the-scenes thread would be to provide functions that could be
plugged into an event loop.

HTH
-Alan


On Fri, Apr 5, 2013 at 11:48 AM, Moebius <cmorris at voicerite.com> wrote:

> I am new to all this, but wanted to ask a couple of questions.  If the
> library sees a heartbeat come in, why can't it just send one back in
> response?  Why would there have to be a message queue involved?
>
>
> Alan Antonuk wrote
> > While I cannot comment on what Dawn ended up doing, I can say a few words
> > about the rabbitmq-c library.
> >
> > Currently the rabbitmq-c only has partial support for AMQP heartbeats:
> the
> > library understands AMQP hearbeats at a protocol level, the library
> > provides an interface for sending and receiving frames that allows
> > heartbeat frames to be sent, however the library does not have an event
> > loop that will automatically handle heartbeats for you.
> >
> > To use heartbeats with rabbitmq-c you would need to provide your own
> event
> > loop/logic to send and receive heartbeat frames.
> >
> > HTH
> > -Alan
>
>
>
>
>
> --
> View this message in context:
> http://rabbitmq.1065348.n5.nabble.com/Is-heartbeat-option-working-in-C-client-tp23785p25909.html
> Sent from the RabbitMQ mailing list archive at Nabble.com.
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>

--f46d044794f372ca6904d9d30cd4
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Because thats not quite how AMQP heartbeats work (I&#39;m =
sorry if some code I posted earlier lead you astray). Heartbeats in AMQP wo=
rk by having each peer (the broker, and the client) have a timer for receiv=
ing something from the other host (something could be useful communication =
like message delivery or publishing, or in the case that a peer has nothing=
 useful to send, it can send a heartbeat). If the timer reaches 0 at either=
 end, that peer is supposed to close the socket immediately.<div>
<br></div><div>From an implementation point of view you need to have 2 time=
rs: one to keep track of when the last time you received data, if this time=
r expires you know that your connection to the broker is dead and you need =
to close the socket. A second timer is needed to keep track of the last tim=
e you sent data, when this timer expires a heartbeat frame needs to be sent=
.</div>
<div><br></div><div>The current design of rabbitmq-c single-threaded event-=
driven, meaning the library itself doesn&#39;t do anything when you&#39;re =
not calling into the library, and has no thread behind the scenes dealing w=
ith these timers. So lets say you received a message, then spent more than =
2 * heartbeat interval processing the message without calling into rabbitmq=
-c, the connection would be closed by the broker.</div>
<div><br></div><div style>Using the current single-threaded event-driven mo=
del of the library I have not been able to come up with a good way to imple=
ment heartbeating that is totally internal to the library (it also needs to=
 be cross platform and not rely on a non-sharable global resource like seti=
timer()/SIGALARM). </div>
<div style><br></div><div style>The best way to fully implement heartbeats =
in rabbitmq-c is to add a thread behind the scenes that deals with these ti=
mers, a second alternative that could be provided by those who don&#39;t wa=
nt the overhead of a separate behind-the-scenes thread would be to provide =
functions that could be plugged into an event loop.</div>
<div style><br></div><div style>HTH</div><div style>-Alan</div></div><div c=
lass=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Fri, Apr 5, 2013=
 at 11:48 AM, Moebius <span dir=3D"ltr">&lt;<a href=3D"mailto:cmorris at voice=
rite.com" target=3D"_blank">cmorris at voicerite.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">I am new to all this, but wanted to ask a co=
uple of questions. =A0If the<br>
library sees a heartbeat come in, why can&#39;t it just send one back in<br=
>
response? =A0Why would there have to be a message queue involved?<br>
<br>
<br>
Alan Antonuk wrote<br>
<div class=3D"im">&gt; While I cannot comment on what Dawn ended up doing, =
I can say a few words<br>
&gt; about the rabbitmq-c library.<br>
&gt;<br>
&gt; Currently the rabbitmq-c only has partial support for AMQP heartbeats:=
 the<br>
&gt; library understands AMQP hearbeats at a protocol level, the library<br=
>
&gt; provides an interface for sending and receiving frames that allows<br>
&gt; heartbeat frames to be sent, however the library does not have an even=
t<br>
&gt; loop that will automatically handle heartbeats for you.<br>
&gt;<br>
&gt; To use heartbeats with rabbitmq-c you would need to provide your own e=
vent<br>
&gt; loop/logic to send and receive heartbeat frames.<br>
&gt;<br>
&gt; HTH<br>
&gt; -Alan<br>
<br>
<br>
<br>
<br>
<br>
</div>--<br>
View this message in context: <a href=3D"http://rabbitmq.1065348.n5.nabble.=
com/Is-heartbeat-option-working-in-C-client-tp23785p25909.html" target=3D"_=
blank">http://rabbitmq.1065348.n5.nabble.com/Is-heartbeat-option-working-in=
-C-client-tp23785p25909.html</a><br>

Sent from the RabbitMQ mailing list archive at Nabble.com.<br>
<div class=3D"HOEnZb"><div class=3D"h5">___________________________________=
____________<br>
rabbitmq-discuss mailing list<br>
<a href=3D"mailto:rabbitmq-discuss at lists.rabbitmq.com">rabbitmq-discuss at lis=
ts.rabbitmq.com</a><br>
<a href=3D"https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-dis=
cuss" target=3D"_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo=
/rabbitmq-discuss</a><br>
</div></div></blockquote></div><br></div>

--f46d044794f372ca6904d9d30cd4--


More information about the rabbitmq-discuss mailing list