Question

I work in a team of people with experience in varied programming languages. Recently we were required to build a report when an order is placed in our system. Our ecommerce store runs on PHP and the program to send the report was written in Java. The major challenge we faced was setting up a way so that the Java process is triggered as soon as the order placed. In the same vein, we have plenty of programs written in Python, Scala etc that need to be coordinated and be aware of when to do a task X when task Y happens.

As of now, our go to solutions to this problem is to setup a cron to routinely check whether a file or value in DB exists and THEN run (simple polling).

I believe a task queue is a right way to solve this problem. However, I'm not sure how to setup one, and how will the Java process know that a task is waiting for it? Also, would a lot of change be required in my PHP program to put something in task queue?

Thanks a lot!

Was it helpful?

Solution

We faced a similar problem, and used RabbitMQ for message transport, and formatted the messages using Google Protocol Buffers.

RabbitMQ is excellent, it just works.

Protocol buffers format the data compactly (far more so than XML or JSon) and is a known schema allowing interoperability between different languages and machine architectures.

On the Java side, the RabbitMQ Client Library will fire an event when a message is ready to be consumed. Read the RabbitMQ docs and follow through some examples, it'll become clear enough fairly quickly.

On the PHP side, there are RabbitMQ libs you can hook into, you authienticate against a Rabbit host and publish a message. I personally haven't used RabbitMQ with PHP, but given how well it's abstracted for other languages it shouldn't be a huge deal.

Licensed under: CC-BY-SA with attribution
scroll top