smart_message 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/deploy-github-pages.yml +38 -0
  3. data/.gitignore +5 -0
  4. data/CHANGELOG.md +30 -0
  5. data/Gemfile.lock +35 -4
  6. data/README.md +169 -71
  7. data/Rakefile +29 -4
  8. data/docs/assets/images/ddq_architecture.svg +130 -0
  9. data/docs/assets/images/dlq_architecture.svg +115 -0
  10. data/docs/assets/images/enhanced-dual-publishing.svg +136 -0
  11. data/docs/assets/images/enhanced-fluent-api.svg +149 -0
  12. data/docs/assets/images/enhanced-microservices-routing.svg +115 -0
  13. data/docs/assets/images/enhanced-pattern-matching.svg +107 -0
  14. data/docs/assets/images/fluent-api-demo.svg +59 -0
  15. data/docs/assets/images/performance-comparison.svg +161 -0
  16. data/docs/assets/images/redis-basic-architecture.svg +53 -0
  17. data/docs/assets/images/redis-enhanced-architecture.svg +88 -0
  18. data/docs/assets/images/redis-queue-architecture.svg +101 -0
  19. data/docs/assets/images/smart_message.jpg +0 -0
  20. data/docs/assets/images/smart_message_walking.jpg +0 -0
  21. data/docs/assets/images/smartmessage_architecture_overview.svg +173 -0
  22. data/docs/assets/images/transport-comparison-matrix.svg +171 -0
  23. data/docs/assets/javascripts/mathjax.js +17 -0
  24. data/docs/assets/stylesheets/extra.css +51 -0
  25. data/docs/{addressing.md → core-concepts/addressing.md} +5 -7
  26. data/docs/{architecture.md → core-concepts/architecture.md} +78 -138
  27. data/docs/{dispatcher.md → core-concepts/dispatcher.md} +21 -21
  28. data/docs/{message_filtering.md → core-concepts/message-filtering.md} +2 -3
  29. data/docs/{message_processing.md → core-concepts/message-processing.md} +17 -17
  30. data/docs/{troubleshooting.md → development/troubleshooting.md} +7 -7
  31. data/docs/{examples.md → getting-started/examples.md} +115 -89
  32. data/docs/{getting-started.md → getting-started/quick-start.md} +47 -18
  33. data/docs/guides/redis-queue-getting-started.md +697 -0
  34. data/docs/guides/redis-queue-patterns.md +889 -0
  35. data/docs/guides/redis-queue-production.md +1091 -0
  36. data/docs/index.md +64 -0
  37. data/docs/{dead_letter_queue.md → reference/dead-letter-queue.md} +2 -3
  38. data/docs/{logging.md → reference/logging.md} +1 -1
  39. data/docs/{message_deduplication.md → reference/message-deduplication.md} +1 -0
  40. data/docs/{proc_handlers_summary.md → reference/proc-handlers.md} +7 -6
  41. data/docs/{serializers.md → reference/serializers.md} +3 -5
  42. data/docs/{transports.md → reference/transports.md} +133 -11
  43. data/docs/transports/memory-transport.md +374 -0
  44. data/docs/transports/redis-enhanced-transport.md +524 -0
  45. data/docs/transports/redis-queue-transport.md +1304 -0
  46. data/docs/transports/redis-transport-comparison.md +496 -0
  47. data/docs/transports/redis-transport.md +509 -0
  48. data/examples/README.md +98 -5
  49. data/examples/city_scenario/911_emergency_call_flow.svg +99 -0
  50. data/examples/city_scenario/README.md +515 -0
  51. data/examples/city_scenario/ai_visitor_intelligence_flow.svg +108 -0
  52. data/examples/city_scenario/citizen.rb +195 -0
  53. data/examples/city_scenario/city_diagram.svg +125 -0
  54. data/examples/city_scenario/common/health_monitor.rb +80 -0
  55. data/examples/city_scenario/common/logger.rb +30 -0
  56. data/examples/city_scenario/emergency_dispatch_center.rb +270 -0
  57. data/examples/city_scenario/fire_department.rb +446 -0
  58. data/examples/city_scenario/fire_emergency_flow.svg +95 -0
  59. data/examples/city_scenario/health_department.rb +100 -0
  60. data/examples/city_scenario/health_monitoring_system.svg +130 -0
  61. data/examples/city_scenario/house.rb +244 -0
  62. data/examples/city_scenario/local_bank.rb +217 -0
  63. data/examples/city_scenario/messages/emergency_911_message.rb +81 -0
  64. data/examples/city_scenario/messages/emergency_resolved_message.rb +43 -0
  65. data/examples/city_scenario/messages/fire_dispatch_message.rb +43 -0
  66. data/examples/city_scenario/messages/fire_emergency_message.rb +45 -0
  67. data/examples/city_scenario/messages/health_check_message.rb +22 -0
  68. data/examples/city_scenario/messages/health_status_message.rb +35 -0
  69. data/examples/city_scenario/messages/police_dispatch_message.rb +46 -0
  70. data/examples/city_scenario/messages/silent_alarm_message.rb +38 -0
  71. data/examples/city_scenario/police_department.rb +316 -0
  72. data/examples/city_scenario/redis_monitor.rb +129 -0
  73. data/examples/city_scenario/redis_stats.rb +743 -0
  74. data/examples/city_scenario/room_for_improvement.md +240 -0
  75. data/examples/city_scenario/security_emergency_flow.svg +95 -0
  76. data/examples/city_scenario/service_internal_architecture.svg +154 -0
  77. data/examples/city_scenario/smart_message_ai_agent.rb +364 -0
  78. data/examples/city_scenario/start_demo.sh +236 -0
  79. data/examples/city_scenario/stop_demo.sh +106 -0
  80. data/examples/city_scenario/visitor.rb +631 -0
  81. data/examples/{10_message_deduplication.rb → memory/01_message_deduplication_demo.rb} +1 -1
  82. data/examples/{09_dead_letter_queue_demo.rb → memory/02_dead_letter_queue_demo.rb} +13 -40
  83. data/examples/{01_point_to_point_orders.rb → memory/03_point_to_point_orders.rb} +1 -1
  84. data/examples/{02_publish_subscribe_events.rb → memory/04_publish_subscribe_events.rb} +2 -2
  85. data/examples/{03_many_to_many_chat.rb → memory/05_many_to_many_chat.rb} +4 -4
  86. data/examples/{show_me.rb → memory/06_pretty_print_demo.rb} +1 -1
  87. data/examples/{05_proc_handlers.rb → memory/07_proc_handlers_demo.rb} +2 -2
  88. data/examples/{06_custom_logger_example.rb → memory/08_custom_logger_demo.rb} +17 -14
  89. data/examples/{07_error_handling_scenarios.rb → memory/09_error_handling_demo.rb} +4 -4
  90. data/examples/{08_entity_addressing_basic.rb → memory/10_entity_addressing_basic.rb} +8 -8
  91. data/examples/{08_entity_addressing_with_filtering.rb → memory/11_entity_addressing_with_filtering.rb} +6 -6
  92. data/examples/{09_regex_filtering_microservices.rb → memory/12_regex_filtering_microservices.rb} +2 -2
  93. data/examples/{10_header_block_configuration.rb → memory/13_header_block_configuration.rb} +6 -6
  94. data/examples/{11_global_configuration_example.rb → memory/14_global_configuration_demo.rb} +19 -8
  95. data/examples/{show_logger.rb → memory/15_logger_demo.rb} +1 -1
  96. data/examples/memory/README.md +163 -0
  97. data/examples/memory/memory_transport_architecture.svg +90 -0
  98. data/examples/memory/point_to_point_pattern.svg +94 -0
  99. data/examples/memory/publish_subscribe_pattern.svg +125 -0
  100. data/examples/{04_redis_smart_home_iot.rb → redis/01_smart_home_iot_demo.rb} +5 -5
  101. data/examples/redis/README.md +230 -0
  102. data/examples/redis/alert_system_flow.svg +127 -0
  103. data/examples/redis/dashboard_status_flow.svg +107 -0
  104. data/examples/redis/device_command_flow.svg +113 -0
  105. data/examples/redis/redis_transport_architecture.svg +115 -0
  106. data/examples/{smart_home_iot_dataflow.md → redis/smart_home_iot_dataflow.md} +4 -116
  107. data/examples/redis/smart_home_system_architecture.svg +133 -0
  108. data/examples/redis_enhanced/README.md +319 -0
  109. data/examples/redis_enhanced/enhanced_01_basic_patterns.rb +233 -0
  110. data/examples/redis_enhanced/enhanced_02_fluent_api.rb +331 -0
  111. data/examples/redis_enhanced/enhanced_03_dual_publishing.rb +281 -0
  112. data/examples/redis_enhanced/enhanced_04_advanced_routing.rb +419 -0
  113. data/examples/redis_queue/01_basic_messaging.rb +221 -0
  114. data/examples/redis_queue/01_comprehensive_examples.rb +508 -0
  115. data/examples/redis_queue/02_pattern_routing.rb +405 -0
  116. data/examples/redis_queue/03_fluent_api.rb +422 -0
  117. data/examples/redis_queue/04_load_balancing.rb +486 -0
  118. data/examples/redis_queue/05_microservices.rb +735 -0
  119. data/examples/redis_queue/06_emergency_alerts.rb +777 -0
  120. data/examples/redis_queue/07_queue_management.rb +587 -0
  121. data/examples/redis_queue/README.md +366 -0
  122. data/examples/redis_queue/enhanced_01_basic_patterns.rb +233 -0
  123. data/examples/redis_queue/enhanced_02_fluent_api.rb +331 -0
  124. data/examples/redis_queue/enhanced_03_dual_publishing.rb +281 -0
  125. data/examples/redis_queue/enhanced_04_advanced_routing.rb +419 -0
  126. data/examples/redis_queue/redis_queue_architecture.svg +148 -0
  127. data/ideas/README.md +41 -0
  128. data/ideas/agents.md +1001 -0
  129. data/ideas/database_transport.md +980 -0
  130. data/ideas/improvement.md +359 -0
  131. data/ideas/meshage.md +1788 -0
  132. data/ideas/message_discovery.md +178 -0
  133. data/ideas/message_schema.md +1381 -0
  134. data/lib/smart_message/.idea/.gitignore +8 -0
  135. data/lib/smart_message/.idea/markdown.xml +6 -0
  136. data/lib/smart_message/.idea/misc.xml +4 -0
  137. data/lib/smart_message/.idea/modules.xml +8 -0
  138. data/lib/smart_message/.idea/smart_message.iml +16 -0
  139. data/lib/smart_message/.idea/vcs.xml +6 -0
  140. data/lib/smart_message/addressing.rb +15 -0
  141. data/lib/smart_message/base.rb +0 -2
  142. data/lib/smart_message/configuration.rb +1 -1
  143. data/lib/smart_message/logger.rb +15 -4
  144. data/lib/smart_message/plugins.rb +5 -2
  145. data/lib/smart_message/serializer.rb +14 -0
  146. data/lib/smart_message/transport/redis_enhanced_transport.rb +399 -0
  147. data/lib/smart_message/transport/redis_queue_transport.rb +555 -0
  148. data/lib/smart_message/transport/registry.rb +1 -0
  149. data/lib/smart_message/transport.rb +34 -1
  150. data/lib/smart_message/version.rb +1 -1
  151. data/lib/smart_message.rb +5 -52
  152. data/mkdocs.yml +184 -0
  153. data/p2p_plan.md +326 -0
  154. data/p2p_roadmap.md +287 -0
  155. data/smart_message.gemspec +2 -0
  156. data/smart_message.svg +51 -0
  157. metadata +170 -44
  158. data/docs/README.md +0 -57
  159. data/examples/dead_letters.jsonl +0 -12
  160. data/examples/temp.txt +0 -94
  161. data/examples/tmux_chat/README.md +0 -283
  162. data/examples/tmux_chat/bot_agent.rb +0 -278
  163. data/examples/tmux_chat/human_agent.rb +0 -199
  164. data/examples/tmux_chat/room_monitor.rb +0 -160
  165. data/examples/tmux_chat/shared_chat_system.rb +0 -328
  166. data/examples/tmux_chat/start_chat_demo.sh +0 -190
  167. data/examples/tmux_chat/stop_chat_demo.sh +0 -22
  168. /data/docs/{properties.md → core-concepts/properties.md} +0 -0
  169. /data/docs/{ideas_to_think_about.md → development/ideas.md} +0 -0
data/docs/index.md ADDED
@@ -0,0 +1,64 @@
1
+ # SmartMessage Documentation
2
+
3
+ <table border="0">
4
+ <tr>
5
+ <td width="30%" valign="top">
6
+ <img src="assets/images/smart_message.jpg" alt="SmartMessage Logo" width="200" />
7
+ </td>
8
+ <td width="70%" valign="top">
9
+
10
+ <string>SmartMessage</strong> is a powerful Ruby framework that transforms ordinary messages into intelligent, self-aware entities capable of routing themselves, validating their contents, and executing business logic. By abstracting away the complexities of transport mechanisms (Redis, RabbitMQ, Kafka) and serialization formats (JSON, MessagePack), SmartMessage lets you focus on what matters: your business logic.
11
+ <br/><br/>
12
+ Think of SmartMessage as ActiveRecord for messaging - just as ActiveRecord frees you from database-specific SQL, SmartMessage liberates your messages from transport-specific implementations. Each message knows how to validate itself, where it came from, where it's going, and what to do when it arrives. With built-in support for filtering, versioning, deduplication, and concurrent processing, SmartMessage provides enterprise-grade messaging capabilities with the simplicity Ruby developers love.
13
+
14
+ </td>
15
+ </tr>
16
+ </table>
17
+
18
+ ## Table of Contents
19
+
20
+ ### Getting Started
21
+ - [Quick Start](getting-started/quick-start.md)
22
+ - [Basic Usage Examples](getting-started/examples.md)
23
+
24
+ ### Core Concepts
25
+ - [Architecture Overview](core-concepts/architecture.md)
26
+ - [Property System](core-concepts/properties.md)
27
+ - [Entity Addressing](core-concepts/addressing.md)
28
+ - [Message Filtering](core-concepts/message-filtering.md)
29
+ - [Message Processing](core-concepts/message-processing.md)
30
+ - [Dispatcher & Routing](core-concepts/dispatcher.md)
31
+
32
+ ### Transports
33
+ - [Transport Layer](reference/transports.md)
34
+ - [Redis Queue Transport](transports/redis-queue-transport.md) ⭐ **Featured**
35
+ - [Redis Transport Comparison](transports/redis-transport-comparison.md)
36
+
37
+ ### Guides
38
+ - [Redis Queue Getting Started](guides/redis-queue-getting-started.md)
39
+ - [Advanced Routing Patterns](guides/redis-queue-patterns.md)
40
+ - [Production Deployment](guides/redis-queue-production.md)
41
+
42
+ ### Reference
43
+ - [Serializers](reference/serializers.md)
44
+ - [Logging System](reference/logging.md)
45
+ - [Dead Letter Queue](reference/dead-letter-queue.md)
46
+ - [Message Deduplication](reference/message-deduplication.md)
47
+ - [Proc Handlers](reference/proc-handlers.md)
48
+
49
+ ### Development
50
+ - [Troubleshooting](development/troubleshooting.md)
51
+ - [Ideas & Roadmap](development/ideas.md)
52
+
53
+ ## Quick Navigation
54
+
55
+ - **New to SmartMessage?** Start with [Quick Start](getting-started/quick-start.md)
56
+ - **Need examples?** Check out [Examples](getting-started/examples.md)
57
+ - **Understanding the architecture?** Read [Architecture Overview](core-concepts/architecture.md)
58
+ - **Having issues?** Visit [Troubleshooting](development/troubleshooting.md)
59
+
60
+ ## Version
61
+
62
+ This documentation is for SmartMessage v0.0.8.
63
+
64
+ For older versions, please check the git tags and corresponding documentation.
@@ -93,10 +93,9 @@ The DLQ operates as a First-In-First-Out queue:
93
93
  ```ruby
94
94
  dlq = SmartMessage::DeadLetterQueue.default
95
95
 
96
- # Add a failed message
96
+ # Add a failed message (accepts decoded message instance)
97
97
  entry = dlq.enqueue(
98
- message_header, # SmartMessage::Header object
99
- message_payload, # Serialized message string
98
+ decoded_message, # SmartMessage::Base instance
100
99
  error: "Connection timeout",
101
100
  retry_count: 0,
102
101
  transport: "Redis",
@@ -505,4 +505,4 @@ logger.info("Test message")
505
505
  assert_includes log_output.string, "Test message"
506
506
  ```
507
507
 
508
- For more information, see the comprehensive logging example at `examples/show_logger.rb`.
508
+ For more information, see the comprehensive logging examples at `examples/memory/15_logger_demo.rb` and `examples/memory/08_custom_logger_demo.rb`.
@@ -1,3 +1,4 @@
1
+
1
2
  # Message Deduplication
2
3
 
3
4
  SmartMessage provides a comprehensive message deduplication system using Deduplication Queues (DDQ) to prevent duplicate processing of messages with the same UUID. The system is designed with handler-scoped isolation, ensuring that different message handlers maintain independent deduplication state.
@@ -92,7 +92,7 @@ MyMessage.unsubscribe(block_id)
92
92
 
93
93
  - Default handler compatibility
94
94
  - Block handler functionality
95
- - Proc parameter handler functionality
95
+ - Proc parameter handler functionality
96
96
  - Lambda handler functionality
97
97
  - Multiple handlers for same message type
98
98
  - Mixed handler types (method + proc)
@@ -114,7 +114,7 @@ MyMessage.unsubscribe(block_id)
114
114
  ### Test Results
115
115
 
116
116
  - **55 total tests** (10 new proc handler tests + existing tests)
117
- - **276 assertions**
117
+ - **276 assertions**
118
118
  - **All tests passing**
119
119
  - **Full backward compatibility** maintained
120
120
 
@@ -153,17 +153,17 @@ MyMessage.unsubscribe(block_id)
153
153
 
154
154
  ## Examples
155
155
 
156
- ### 1. New Working Example (`examples/05_proc_handlers.rb`)
156
+ ### 1. New Working Example (`examples/memory/07_proc_handlers_demo.rb`)
157
157
 
158
158
  Complete demonstration of all handler types:
159
159
  - Default handler (self.process)
160
- - Block handlers (inline logic)
160
+ - Block handlers (inline logic)
161
161
  - Proc handlers (reusable logic)
162
162
  - Lambda handlers (functional style)
163
163
  - Method handlers (service classes)
164
164
  - Handler management and unsubscription
165
165
 
166
- ### 2. Enhanced IoT Example (`examples/04_redis_smart_home_iot.rb`)
166
+ ### 2. Enhanced IoT Example (`examples/redis/01_smart_home_iot_demo.rb`)
167
167
 
168
168
  Production-ready Redis transport example showing real-world usage patterns.
169
169
 
@@ -234,6 +234,7 @@ Production-ready Redis transport example showing real-world usage patterns.
234
234
  ## Future Enhancements
235
235
 
236
236
  Potential areas for future development:
237
+
237
238
  - Handler priority/ordering
238
239
  - Conditional handler execution
239
240
  - Handler metrics and monitoring
@@ -244,4 +245,4 @@ Potential areas for future development:
244
245
 
245
246
  The enhanced subscription functionality provides SmartMessage users with powerful, flexible options for message processing while maintaining the simplicity and elegance of the original design. The implementation is production-ready, thoroughly tested, and fully documented.
246
247
 
247
- This enhancement positions SmartMessage as a more versatile and developer-friendly messaging framework suitable for both simple prototypes and complex enterprise applications.
248
+ This enhancement positions SmartMessage as a more versatile and developer-friendly messaging framework suitable for both simple prototypes and complex enterprise applications.
@@ -26,7 +26,7 @@ The default serializer that converts messages to/from JSON format.
26
26
 
27
27
  ```ruby
28
28
  # Basic usage
29
- serializer = SmartMessage::Serializer::JSON.new
29
+ serializer = SmartMessage::Serializer::Json.new
30
30
 
31
31
  # Configure in message class
32
32
  class UserMessage < SmartMessage::Base
@@ -35,7 +35,7 @@ class UserMessage < SmartMessage::Base
35
35
  property :preferences
36
36
 
37
37
  config do
38
- serializer SmartMessage::Serializer::JSON.new
38
+ serializer SmartMessage::Serializer::Json.new
39
39
  end
40
40
  end
41
41
 
@@ -569,7 +569,5 @@ end
569
569
 
570
570
  ## Next Steps
571
571
 
572
- - [Custom Serializers](custom-serializers.md) - Build your own serializer
573
572
  - [Transports](transports.md) - How serializers work with transports
574
- - [Message Headers](headers.md) - Understanding message metadata
575
- - [Examples](examples.md) - Real-world serialization patterns
573
+ - [Examples](../getting-started/examples.md) - Real-world serialization patterns
@@ -137,6 +137,13 @@ Production-ready Redis pub/sub transport for distributed messaging.
137
137
  - Configurable connection parameters
138
138
  - Background message subscription threads
139
139
 
140
+ > **💡 Redis Transport Options:** SmartMessage provides three Redis-based transports:
141
+ > - **Redis (Basic)** - Simple pub/sub for basic scenarios
142
+ > - **Redis Enhanced** - Pattern-based routing with backwards compatibility
143
+ > - **Redis Queue** - Persistent queues with load balancing
144
+ >
145
+ > See the [Redis Transport Comparison](../transports/redis-transport-comparison.md) for detailed differences and usage guidance.
146
+
140
147
  **Usage:**
141
148
 
142
149
  ```ruby
@@ -166,12 +173,12 @@ class OrderMessage < SmartMessage::Base
166
173
  url: 'redis://localhost:6379',
167
174
  db: 1
168
175
  )
169
- serializer SmartMessage::Serializer::JSON.new
176
+ serializer SmartMessage::Serializer::Json.new
170
177
  end
171
178
 
172
- def self.process(message_header, message_payload)
173
- order_data = JSON.parse(message_payload)
174
- order = new(order_data)
179
+ def self.process(decoded_message)
180
+ # decoded_message is already a message instance
181
+ order = decoded_message
175
182
  puts "Processing order #{order.order_id} for $#{order.amount}"
176
183
  # Your business logic here
177
184
  end
@@ -243,7 +250,7 @@ redis_transport = SmartMessage::Transport.create(:redis,
243
250
  [OrderMessage, PaymentMessage, ShippingMessage].each do |msg_class|
244
251
  msg_class.config do
245
252
  transport redis_transport
246
- serializer SmartMessage::Serializer::JSON.new
253
+ serializer SmartMessage::Serializer::Json.new
247
254
  end
248
255
 
249
256
  # Subscribe to each message type (creates separate Redis subscriptions)
@@ -285,7 +292,7 @@ class ProductionMessage < SmartMessage::Base
285
292
  reconnect_attempts: 10,
286
293
  reconnect_delay: 5
287
294
  )
288
- serializer SmartMessage::Serializer::JSON.new
295
+ serializer SmartMessage::Serializer::Json.new
289
296
  logger Logger.new(STDOUT)
290
297
  end
291
298
  end
@@ -302,7 +309,7 @@ class TestMessage < SmartMessage::Base
302
309
  db: 15, # Use separate database for tests
303
310
  auto_subscribe: true
304
311
  )
305
- serializer SmartMessage::Serializer::JSON.new
312
+ serializer SmartMessage::Serializer::Json.new
306
313
  end
307
314
  end
308
315
 
@@ -313,6 +320,121 @@ def setup
313
320
  end
314
321
  ```
315
322
 
323
+ ### Redis Enhanced Transport
324
+
325
+ Advanced Redis transport with intelligent pattern-based routing and RabbitMQ-style capabilities.
326
+
327
+ **Features:**
328
+ - Pattern-based subscriptions with wildcard support (`*` matching)
329
+ - Dual channel publishing for backwards compatibility
330
+ - Fluent API for building complex subscription patterns
331
+ - Enhanced routing with 3-part channel names: `message_type.from.to`
332
+ - Convenience methods for common routing patterns
333
+ - Service-oriented messaging patterns
334
+
335
+ ![Redis Enhanced Architecture](../assets/images/redis-enhanced-architecture.svg)
336
+
337
+ **Usage:**
338
+
339
+ ```ruby
340
+ # Create enhanced transport
341
+ transport = SmartMessage::Transport::RedisEnhancedTransport.new(
342
+ url: 'redis://localhost:6379',
343
+ db: 0,
344
+ auto_subscribe: true
345
+ )
346
+
347
+ # Configure message with enhanced transport
348
+ class OrderMessage < SmartMessage::Base
349
+ from 'e-commerce-api'
350
+ to 'order-processor'
351
+
352
+ transport transport
353
+ serializer SmartMessage::Serializer::Json.new
354
+
355
+ property :order_id, required: true
356
+ property :amount, required: true
357
+ end
358
+
359
+ # Pattern-based subscriptions
360
+ transport.subscribe_pattern("ordermessage.*.*") # All order messages
361
+ transport.subscribe_pattern("*.payment_gateway.*") # All from payment gateway
362
+ transport.subscribe_to_recipient('order-processor') # Convenience method
363
+ transport.subscribe_to_alerts # Emergency patterns
364
+
365
+ # Fluent API subscriptions
366
+ transport.where.from('web-app').to('user-service').subscribe
367
+ transport.where.type('OrderMessage').from('api').subscribe
368
+ transport.where.from('monitoring').subscribe
369
+
370
+ # Publishing (goes to BOTH channels for compatibility)
371
+ order = OrderMessage.new(order_id: 'ORD-123', amount: 99.99)
372
+ order.publish
373
+ # Publishes to:
374
+ # - "OrderMessage" (original format)
375
+ # - "ordermessage.e_commerce_api.order_processor" (enhanced format)
376
+ ```
377
+
378
+ **Pattern Wildcards:**
379
+ - `*` - Matches exactly one segment
380
+ - `ordermessage.*.*` - All order messages regardless of from/to
381
+ - `*.payment_service.*` - All messages from payment service
382
+ - `*.*.order_processor` - All messages to order processor
383
+
384
+ **Convenience Methods:**
385
+ ```ruby
386
+ transport.subscribe_to_recipient('service-name') # *.*.service-name
387
+ transport.subscribe_from_sender('api-gateway') # *.api-gateway.*
388
+ transport.subscribe_to_type('OrderMessage') # ordermessage.*.*
389
+ transport.subscribe_to_alerts # Multiple alert patterns
390
+ transport.subscribe_to_broadcasts # *.*.broadcast
391
+ ```
392
+
393
+ **Fluent API:**
394
+ ```ruby
395
+ # Single conditions
396
+ transport.where.from('api').subscribe # *.api.*
397
+ transport.where.to('database').subscribe # *.*.database
398
+ transport.where.type('LogMessage').subscribe # logmessage.*.*
399
+
400
+ # Combined conditions
401
+ transport.where.from('web').to('api').subscribe # *.web.api
402
+ transport.where.type('Order').from('shop').subscribe # order.shop.*
403
+ ```
404
+
405
+ **Options:**
406
+ - `url` (String): Redis connection URL (default: 'redis://localhost:6379')
407
+ - `db` (Integer): Redis database number (default: 0)
408
+ - `auto_subscribe` (Boolean): Automatically start subscriber threads (default: true)
409
+ - `reconnect_attempts` (Integer): Connection retry attempts (default: 5)
410
+ - `reconnect_delay` (Integer): Delay between retries in seconds (default: 1)
411
+
412
+ **Backwards Compatibility:**
413
+
414
+ The Enhanced Transport maintains full backwards compatibility with the basic Redis transport by publishing to both channel formats:
415
+
416
+ ```ruby
417
+ # Enhanced transport publishes to BOTH:
418
+ # 1. "OrderMessage" (basic format - for backwards compatibility)
419
+ # 2. "ordermessage.from_service.to_service" (enhanced format - for pattern matching)
420
+
421
+ # Basic Redis transport can still subscribe to "OrderMessage"
422
+ # Enhanced transport can use patterns on the enhanced format
423
+ ```
424
+
425
+ **Use Cases:**
426
+ - Microservices architectures requiring sophisticated routing
427
+ - Migration from basic Redis transport (maintains compatibility)
428
+ - Development environments needing flexible message routing
429
+ - Applications requiring RabbitMQ-style patterns without RabbitMQ setup
430
+ - Service-to-service communication with intelligent filtering
431
+
432
+ **Performance:**
433
+ - Minimal overhead over basic Redis transport
434
+ - Client-side pattern matching (slightly higher CPU usage)
435
+ - Dual publishing increases Redis network traffic by ~2x
436
+ - Excellent performance for most production scenarios
437
+
316
438
  ## Transport Interface
317
439
 
318
440
  All transports must implement the `SmartMessage::Transport::Base` interface:
@@ -411,7 +533,7 @@ class OrderMessage < SmartMessage::Base
411
533
  # All instances use this transport by default
412
534
  config do
413
535
  transport SmartMessage::Transport.create(:memory, auto_process: true)
414
- serializer SmartMessage::Serializer::JSON.new
536
+ serializer SmartMessage::Serializer::Json.new
415
537
  end
416
538
  end
417
539
  ```
@@ -689,7 +811,7 @@ end
689
811
 
690
812
  ## Next Steps
691
813
 
692
- - [Custom Transports](custom-transports.md) - Build your own transport
814
+ - [Redis Transport Comparison](../transports/redis-transport-comparison.md) - Detailed comparison of Redis, Enhanced, and Queue transports
693
815
  - [Serializers](serializers.md) - Understanding message serialization
694
- - [Dispatcher](dispatcher.md) - Message routing and processing
695
- - [Examples](examples.md) - Real-world transport usage patterns
816
+ - [Dispatcher](../core-concepts/dispatcher.md) - Message routing and processing
817
+ - [Examples](../getting-started/examples.md) - Real-world transport usage patterns