Observer versus reactor pattern

I studied both, but could not find any real difference, am I missing something? On the Internet, some people say that Observer needs to process only one event, while there are many reactors - but I do not consider this a real difference, because the reactor can be seen in the same way as many observers. Is there any difference, or is the new Reactor name just cooler than Observer?

Thanks Carlo

+7
design-patterns
source share
1 answer

Reactor Pattern uses an intermediate service handler that demultiplexes the requests and sends the correct handler.

An observational template requires Observers to register with the subject, and then pushes notifications to all registered observers when an event occurs.

An important difference is that the Reactor pattern handles dispatching using a central request handler, while the Observer pattern allows consumers to directly contact manufacturers.

In practice, the Observer pattern can provide greater flexibility for dynamic registration and deregistration of consumers. In very high concurrency applications, it also offers the advantage of not having a single intermediate controller that impedes bandwidth. The Lapsed Listener problem also matters, which occurs when consumers forget to de-register with an object when they no longer want to receive notifications. In garbage collections, this often prevents the GC from collecting these event handlers and thus losing them and any links they store. This is usually not possible with a reactor template that usually does not use dynamic logging (although this is theoretically possible).

+7
source share

All Articles