Resource Usage: More connections/resources with many elevators
💼 Pattern Subscription (PSUBSCRIBE)
Pros
Dynamic Discovery: Automatically handles new elevators without code changes
Centralized Processing: Single point for all command processing
Simplified Architecture: One subscription to manage
Future-Proof: Naturally accommodates system growth
Cons
Higher Message Volume: Single handler processes all messages
Extraction Overhead: Need to parse elevator ID from channel names
Single Point of Failure: If handler crashes, affects all elevators
Potential Bottleneck: High message volume could cause processing delays
Best Use Cases
Choose SUBSCRIBE when:
Fixed, known number of elevators
Distributed architecture where different services handle different elevators
Performance is critical and targeted message routing is important
Highly isolated error domains are required
Choose PSUBSCRIBE when:
Number of elevators may change dynamically
Centralized management architecture
Simpler code and maintenance is prioritized
System-wide monitoring and logging is desired
Recommendation
For most elevator systems, PSUBSCRIBE provides the best balance of simplicity and flexibility. Unless you have performance constraints or specific isolation requirements, the pattern-based subscription will likely serve you better in the long run, especially as your system grows.
The key question is: "Is your elevator system more likely to benefit from flexibility or from isolation and targeted performance?"
💼 Direct Subscription (SUBSCRIBE)
Pros
Cons
-Limited Flexibility: Requires knowing elevator IDs upfront
💼 Pattern Subscription (PSUBSCRIBE)
Pros
Dynamic Discovery: Automatically handles new elevators without code changes
Centralized Processing: Single point for all command processing
Simplified Architecture: One subscription to manage
Future-Proof: Naturally accommodates system growth
Cons
Higher Message Volume: Single handler processes all messages
Extraction Overhead: Need to parse elevator ID from channel names
Single Point of Failure: If handler crashes, affects all elevators
Potential Bottleneck: High message volume could cause processing delays
Best Use Cases
Choose SUBSCRIBE when:
Choose PSUBSCRIBE when:
Recommendation
For most elevator systems, PSUBSCRIBE provides the best balance of simplicity and flexibility. Unless you have performance constraints or specific isolation requirements, the pattern-based subscription will likely serve you better in the long run, especially as your system grows. The key question is: "Is your elevator system more likely to benefit from flexibility or from isolation and targeted performance?"