📜 ⬆️ ⬇️

Overview of MQ (Messages queue) for use in projects on PHP. Part 2

We continue to explore the topic of this class of software as message queues in relation to PHP web systems. In the last article, we looked at some software, in particular, representatives of both the topmost area ( Apache Active MQ , whose capabilities are already at the level of corporate software), and fairly simple options, for example, MQS . But some rather interesting projects remained to be considered, so our research continues.

Starling Message Queue - a fairly simple system developed by Blaine Cook from Twiitter on Ruby, supports work on the Memcache protocol, which means it allows any system that understands this protocol to connect and work.

And the last project that I would like to consider came to us from the field of desktop applications. D-Bus is a system of interprocess and inter-program interactions, which is used in the GNOME windowing environment ( more details in Wikipedia ). This, however, is not an absolutely pure MQ system, D-Bus implements the concept of signals / slots (the PHP implementation of which I consider to be just excellent in ezComponents and which I will write later separately). However, looking through the mailing lists of this project (and it is part of freedesktop.org ) I came across messages that there is a implementation on PHP - D-BUS PHP Binding (this is just a connector to the existing system). But there are ports to other languages ​​and platforms - on win32 systems , on the .NET platform , as well as for Java, Python and other languages, including, of course, Perl. The PHP version is called PHP DBus and is developed by Japanese developers, the current implementation is version 0.1 (as an extension module to PHP). By the way, based on this library, developers have made an interlayer over the Skype API and can interact with the installed Skype directly from the PHP application.

Since traditionally already, message systems are the most developed in the Java world, PHP projects began with what was created as a wrapper over existing Java systems, ensuring their use in PHP applications. In particular, this is a bundle of two projects - Mantaray (in Java, a distributed P2P system for exchanging messages in a distributed network over HTTP / HTTPS protocols, although not updated since 2006) and PHPMQ , which is a wrapper for the JMS protocol and uses PHP / Java Integration extension , another interesting project for organizing the collaboration of two environments. Unfortunately, it is not worthwhile to consider both systems for serious work, but as research systems, completely.
')
Dropr is perhaps the first and only serious project entirely in PHP that implements message queues and is used in real projects. Dropr is positioned as a distributed framework for queuing messages. The system is resistant to network or hardware failures — each node has its own independent message storage, in the local file system or database. Dropr has a distributed architecture without a single point of failure, and each node can be both a server and a client. The server itself is designed as a separate daemon, with which the client script and PHP Dropr library interact. The daemon stores messages locally or sends them over the network to another node using multi-threaded loading using a cURL module. By the way, as far as I figured out, the daemon is executed in the same way in the form of a PHP script that runs separately and constantly hangs in the server’s memory.

This system was created and is used in a large project, Jimdo (in fact, a service for simple creation and hosting of free pages), in which it provides a three-node geographically distributed cluster. To the credit of Dropr, there are some service tools in it, such as viewing the queue status and managing it, however, as the creators note, there is no documentation other than the commented code and installation and usage manuals.

Unfortunately, these are probably all the projects that I could find and see. As you can see, most of them are written in Java, and if you want to somehow use this functionality in PHP applications, you need either a wrapper library and interaction with daemons on the network or sockets, or use PHP / Java integration tools, however, it is quite nontrivial (although there are already at least three such options, and I will write a separate article about them soon). If this does not apply to you, consider working with pure PHP Dropr solutions, but accept the fact that you will only be provided with basic functionality. Depending on the needs and usage scenarios, you can consider a dedicated server, for example, based on memcacheQ , which will provide fast work, reliability and a unified interface, or you can still look again towards more serious and complex solutions based on Java, Erlang, C / C ++ or Ruby, which may be preferable if you have a web project on RoR.

And on the next, one of the original projects. Browser DBus Bridge is a connector to the D-Bus bus from JavaScript code that works in Gecko / WebKit browsers on systems that support D-Bus interaction. The meaning of the project is probably to expand the interaction of web applications with external software, for example, automatically launching the same Skype or other software installed in the system. However, here we are faced with security issues, so the full potential will be revealed only in your own developments, when you create a client for your application based on the Gecko engine and compile with it all the necessary libraries (after all, in a regular browser on this engine, even running on platform with D-Bus, no support for working with it).

PS I will answer the question asked me in the previous article - which system I chose. So far, no, I consider and think about architecture in general. There are two options - launching all PHP applications on the Java platform and working directly with some Java project, but with something easier than Apache Active MQ, or using a different, but close, architecture based on signals and slots ( similarly to D-Bus), for it all the more there is an excellent implementation in ezComponents . Although this, of course, is not quite MQ, but will cover most of the requirements. Exactly for networking with other nodes, here we are already considering using either memcacheQ , or ezComponents extension for interacting with Dropr, or using a dedicated Spread- based server, especially since it has a module for PHP, and the project itself is serious and functional.

Source: https://habr.com/ru/post/45891/


All Articles