I created a super simple SQS to HTTP worker in node.js queue for PHP

Node.js SQS to HTTP worker/daemon/background process

Welcome to this silly little utility program. It provides an intermediary link between an SQS message queue and a backend HTTP system. It is very simple. All you do is push a message to an SQS queue and this program will receive it and forward it to an HTTP server. Just plop this handy little program on the server with Apache or Nginx, or behind a firewall that points to a load balanced group of webservers, change some of the settings in the source code and run it. The message retrieved from SQS is POSTed to HTTP. Given that SQS allows you to send a million messages per month, this could be a very cheap, simple, means of having a worker queue in PHP without having any infrastructure to manage.

Also, I’m not a node.js developer. If I totally messed this up feel free to rewrite it with a pull request.

Don’t forget to

npm install


node bin/start.js

There is no PHP library to use it. If you want to build your own plumbing for making it work you can. You could do something as simple as having this SQS payload:

    "job": "Jobs\WriteMessage",
        "payload": "This is a message"

push to this bootstrap file

namespace Jobs {
   class WriteMessage {
       public function execute($message) {
             file_put_contents('/tmp/message', $message);

$content = file_get_contents('php://input');
$data = json_decode($content, true);
$class = $data['job'];
$obj = new $class();

or thereabouts. I don’t know. I wrote that code without testing it. But that’s how simple it would be.

You can get it on GitHub

Have fun.

I also did one for FastCGI

Leave a Reply

Your email address will not be published. Required fields are marked *