I have a REST based web service system. I need to find a way to support publish/subscribe model here. As you know REST the communication between client and server is HTTP protocol. I use apache (PHP) web server in the backend to server all REST requests. The question is how to use PHP or whatever (in the web server side) to support this kind of Pub/Sub model. One typical scenario would be:
1) Client subscribes for a change in an object (GET /config/object/?type=async) 2) Client does not block with this request as it is async call. 3) Server accept the subscription and waits for the event. 4) Server publishes the client with the required data as and when the event happens.
I basically need to know how to implement all of these four steps above.
You are probably looking for something like PubSubHubbub -
Letting PubSub implement the hub for you means you don't need blocking calls to the server.
They already have implemented example Subscribers and Publishers in different languages.
If haven't already, you should read Roy Fielding's take on the various approaches to PubSub. http://roy.gbiv.com/untangled/2008/paper-tigers-and-hidden-dragons