yiisoft/yii2 — pull request #2378 by nineinchnick (2014-02-09 10:18:49+00:00)
Title: WIP, a message queue interface and three implementations

Resolves #492. __WIP - do not merge, request for comments.__

Introducing a generic message queue interface with following features:

* A single message queue as an application component
* Three implementations: System V, Redis and DB (SQL)
* Publish/Subscribe (delivery to multiple queues) with filtering by categories
* Peeking and reserving/locking messages with a timeout
* Blocking mode to allow running a consumer/worker that waits for messages
* Yii events

The design is suppose to allow creating job queues as well as messaging, notifications, logging, audits etc.

This PR is a request for comments. It means there are a few design issues to discuss:

1. Blocking
Blocking is required to be able to implement an efficient consumer fired up as a deamon that waits for arriving messages. This is implemented in the Redis and SysV queues and could be done for Db queue but requires a db engine specific sql expressions (locking, notifications in PostgreSQL and queus in MsSQL).
Currently it's a property of the queue component. Should it be an argument to the send/receive methods?

2. Db implementation
Should AR models be used? They do simplify the queue interface implementation by removing raw SQL from it. Can the namespace hierarchy be improved?

3. Separating PubSub interface
Should the PubSub methods be extracted into a separate interface? A good example is the SysV implementation, which provide only a single queue. It could implement the PubSub interface by storing subscriptions somewhere else, ie a database.

4. Should a console controller be included?

5. Are there any other implementations that should be available?

Note: db implementation is important to be able to use in a local dev enviroment (like mail with file delivery) and in enviroments where services like Redis cannot be installed (shared hosting). It CAN be acceptable in low traffic/congestion systems.

Note: the code here may not actually run. It has been ported into the framework from the [yii2-nfy module](https://github.com/nineinchnick/yii2-nfy) for discussion of the basic design.

Tests will be added after current design will be accepted and/or changes will be made.