Compare in-process Observer with broader pub-sub models in Java so local listeners are not confused with brokered event systems.
Observer and pub-sub both distribute reactions to events, but they operate at different scales and with different assumptions.
flowchart LR
A["Observer"] --> B["Subject knows listener registration"]
B --> C["Usually in-process and direct"]
D["Pub-sub"] --> E["Publisher and subscriber decoupled by topic or broker"]
E --> F["Often distributed or infrastructure-backed"]
Observer is usually:
Pub-sub is usually:
If one object inside the same process needs to notify listeners, start by thinking Observer.
If events need routing through topics, infrastructure, or service boundaries, think pub-sub or event-driven messaging instead.