<div class="im">2011/4/25 Ben Browitt <span dir="ltr"><<a href="mailto:ben.browitt@gmail.com" target="_blank">ben.browitt@gmail.com</a>></span><br></div><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">I have a service on one server that need to get messages from several websites on remote servers.<br>A message will be triggered by a user action in a website. For example, when a user login or post a comment.<br>
Messages are small, frequency will be low and it is not critical if messages are lost.<br></div></blockquote></div><div><br>First question: if message volume is low, maybe a synchronous client will do just fine? They are somewhat easier to<br>
use.<br> </div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div dir="ltr">The easiest thing to do is send an http request from the website to the service but that will block the user request.<br>
Another option is to store messages in a database on the website server
and poll it with a cron job or a request from the service but it's
dirty.<br>
<br></div></blockquote></div><div><br>Several databases provide publish/subscribe implementation of some kind, for example, PostgreSQL and Redis.<br> </div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div dir="ltr">I would like to use rabbitmq for this.<br>The service will have a rabbitmq server with a client for each website.<br>Each website will have a rabbitmq client that will publish messages to the server.<br></div>
</blockquote></div><div><br>This is a pretty common use case for RabbitMQ, as far as I can tell.<br> </div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div dir="ltr">Websites will use php, python or ruby.<br>
Do I need to use a different client for each language?<br></div></blockquote></div><div><br>Yes. I am not aware of any way to use, say, a Python library from Ruby or vice versa, and<br>
if doing so is worth the effort anyway.<br>
<br>I am not the right person to recommend Python and PHP libraries, <br>
but if you want an asynchronous Ruby client, amqp gem [1] is a very
widely used option. More importantly, it is actively maintained.<br>
I recommend you to use version in git repository (worry not that it is pre-release; we are very<br>
close to final release and majority of work is now on paying off documentation debt [2]) because all examples are<br>now written for it. All maintainers are on this list.<br> </div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div dir="ltr"><br>Is the client async, meaning that the php code will ask it to send the message but won't need to wait for it?<br><br></div></blockquote><div> </div></div><div>that function that sends your message won't wait for message to be sent. Instead, it will return immediately.<br>
<br><br>My impression is that publishing messages directly to RabbitMQ without any extra layers in the middle would<br>work fine for your case. Sure, using 3 client libraries is a bit annoying but I am not aware of any messaging solution that<br>
lets you reuse Python libraries from PHP or something like that. JVM languages all can use Java client, though.<br><br><br>Hope this helps.<br><br>1. <a href="https://github.com/ruby-amqp/amqp" target="_blank">https://github.com/ruby-amqp/amqp</a><br>
2. <a href="http://rdoc.info/github/ruby-amqp/amqp/master/frames" target="_blank">http://rdoc.info/github/ruby-amqp/amqp/master/frames</a><br clear="all"></div></div>-- <br><font color="#888888">MK</font>