I am creating an OO PHP application that will run through several nodes and be relatively inactive in nature, and I need to implement a proper publisher subscriber ( http://en.wikipedia.org/wiki/Observer_pattern / http://sourcemaking.com/ design_patterns / Observer / php ) style events.
My question is: how can I handle events?
In my application, we use technologies such as Cassandra, Redis, Mongo, and RabbitMQ.
I know that PHP has an EXTENSION event, but from what I can say, it is in a state - or if something like memcached is involved, it can be used in this node ... but my application will be distributed across several nodes .
So, let's look at an example: In Node 1, the metric is updated (metric identifier 37), and everything that subscribes to this indicator needs to be updated. This publishes the change and the change as it makes the update.
I have something that subscribed to the updated Metric ID 37, for example Metric 38, you may need to recount when the Metric 37 value changes.
Metric 38 is currently created and used in Node 2 in process ID 1011 ... How does Metric 37 tell Metric 38 on Node 2 (process ID 1011 in this case) to run a signed function?
Metric 39 subscribes to Metric 38, which is updated but not created anywhere ... How does Metric 39 update when Metric 38 completes the update?
I was thinking of something like using RabbitMQ as an event queue manager, and on every Node there is an event-consumer application like a daemon that reads events in an event queue (for load balancing / work distribution).
Then the consumer sees "Metric: 38: Updated", he checks something like Redis for everything that is subscribed to "Metric: 38: Updated" and gets the value ("What: Function: Values") and does something like call_user_func_array (array ($, that, function $), $ values); .... but it looks like it can cause excessive load and some synchronization problems ...
I use Doctrine MongoDB ODM to save my objects ... To deal with synchronization issues, I thought of something like this: Objects can have a version number ... (version = 1.0) And redis can be used to quickly link to the latest version object (ObjectVersion: ObjectType: ObjectId) = 1.1 And when the getter is called on the property of the object, which is marked as @critical (such as isDeleted, cash balances, etc.), It can check if the version identifier of version # is equal to redis and update its values ββfrom mongo if necessary to ...
An alternative setup uses amphp/amp ( http://amphp.org/docs/amp/reactor-concepts.html ) and some form of RPC to synchronize nodes
Since I'm pretty new to web development (moving from C #) and stateless and spread. I thought it would be nice to ask the community if anyone has any better suggestions?