Design a Pub-Sub System — Concept Check
Questions on Design a Pub-Sub System. Build an in-process publish-subscribe system with topics, async delivery via ExecutorService, subscription management, and configurable delivery guarantees.
Questions in this quiz
8 questions on Design a Pub-Sub System — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer notices that messages are not consistently reaching all subscribers in a Pub-Sub system. What could be the issue?
- AMessages are not being timestamped.
- BThe topic names are not unique.
- CThe thread pool size is too small for the load.
- DSubscribers are holding references to publishers.
2.In a Pub-Sub system, a subscriber is not receiving messages after a certain point. What is a likely cause?
- AThe publisher stopped publishing messages.
- BThe subscriber's onMessage() method is empty.
- CThe subscriber called cancel() on its subscription.
- DThe topic was deleted from the EventBus.
3.What happens if a subscriber throws an exception during message processing in this Pub-Sub system?
- AAll message deliveries are halted until the issue is resolved.
- BThe EventBus shuts down the executor service.
- CThe message is re-delivered to the same subscriber.
- DThe exception is logged, and other subscribers continue receiving messages.
4.A developer wants to ensure that a message is delivered exactly once to each subscriber. Which DeliveryGuarantee should they use?
- AAT_MOST_ONCE
- BNONE
- CAT_LEAST_ONCE
- DEXACTLY_ONCE
5.A Pub-Sub system's performance degrades as more topics are added. What might be the problem?
- AThe DeliveryGuarantee is set to AT_LEAST_ONCE.
- BThe EventBus is using a single-threaded executor.
- CSubscribers are not properly decoupled from publishers.
- DThe CopyOnWriteArrayList is causing excessive memory usage.
6.Which pattern is primarily used in the design of the Pub-Sub system?
- ASingleton pattern
- BObserver pattern
- CDecorator pattern
- DFactory pattern
7.A subscriber is receiving duplicate messages. What might be the cause?
- AThe subscriber is subscribed to multiple topics.
- BThe topic name is incorrect.
- CThe Message class lacks a unique ID.
- DThe DeliveryGuarantee is set to AT_LEAST_ONCE.
8.What is the role of the CopyOnWriteArrayList in the Topic class?
- ATo handle message retries on failure.
- BTo store messages temporarily before delivery.
- CTo ensure messages are delivered in order.
- DTo manage subscribers thread-safely without locking.