views:

370

answers:

2
+3  Q: 

comet vs pubsub..?

may i know what is the different between these 2 approach ? can explain in lay man terms?

+4  A: 

Publish-subscribe is a means of asynchronous communication that decouples publishers from subscribers. Rather than addressing messages to particular subscribers, publishers publish messages on a topic. Subscribers subscribe to the topic. A given topic can have many publishers and many subscribers.

For example, in a trading system, trades of Google shares might be published on a topic of "Trade.GOOG". Subscribers could then listen to trades in particular stocks by listening to the requisite topics.

Comet is a Web-based technique for server-push using long-lived HTTP connections.

Imagine a Poker website. Your browser could make a connection to the server, which would essentially hang until it was your turn to do something (raise, call, etc) rather than you hitting refresh every few seconds to see if you need to do something. Polling is another solution to this.

The similarity they both have is that they are essentially a means of asynchronous communication but otherwise are dissimilar.

cletus
i understand about comet that you explained. but on your pubsub... in lay man terms. please
cometta
Publish-Subscribe would be the real-world equivalent of a magazine. You subrscribe to it, and receive it when they publish. The magazine isn't just for you...it's for every subscriber.
Justin Niessner
does that mean, it's better than using comet ?
cometta
+5  A: 

Comet is a technology for pushing real-time data to a web browser - so the page can continually update. For more details see this page about Comet.

Pub/Sub (or Publish/Subscribe) is not different to Comet, it is a way of telling a Comet server what data you want to receive (Subscribe) and sending data to other subscribers (Publish). Many Comet servers implement the pub/sub model.

Real world examples in StreamHub Comet Server:

Subscribe: I want to receive news about Google:

hub.subscribe("/news/google", function(sTopic, oData) { alert("Received news article about Google: " + oData.Article});

Publish: I want to contribute some news about Google:

hub.publish("/news/google", "{'Title':'Google Expanding Access To Wave Soon, First Impressions','Article':'According to Google, included in this group of early testers will be some of the businesses using Google Apps. In anticipation of this wider release, ...'}");

Anyone subscribed to the topic "/news/google" will receive the article I published above - that's how pub/sub works.

DLauer