Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Publish-subscribe and Reactor patterns looking very similar to me. How they are different?

In both patterns a message is getting passed to subscribers indirectly (listeners in reactor pattern).

I feel observer pattern is very similar to two other patterns too.

What are key differences between those patterns?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

As I can see from the link, PubSub pattern is not an OOP pattern, but rather messaging pattern, which is a network architectural pattern.

Reactor pattern is something related to servers' request handling with single-threaded event loop. Again, the link shows some good examples like Node.js, Netty, Twisted, etc.

Finally, Observer is OOP design-pattern which describes a way of interaction between objects in OO-code.

So those three patterns are from different domains.

share|improve this answer
add comment

Reactor = single threaded event loop that receives and processes requests. Those requests could be loaded in batches from a file, via SMTP and/or HTTP. Processed concurrently responses are delivered when ready rather than sequentially.

Publishers emit. Subscribers consume.

Publishers + Subscribers = Observer pattern (Heads First Design Patterns). Observers fire sequentially and usually block until they complete.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.