smart_message 0.0.10 → 0.0.13

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 (149) 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 +64 -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} +80 -145
  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} +103 -89
  32. data/docs/{getting-started.md → getting-started/quick-start.md} +47 -23
  33. data/docs/index.md +64 -0
  34. data/docs/{dead_letter_queue.md → reference/dead-letter-queue.md} +2 -3
  35. data/docs/{logging.md → reference/logging.md} +1 -1
  36. data/docs/{message_deduplication.md → reference/message-deduplication.md} +1 -0
  37. data/docs/{proc_handlers_summary.md → reference/proc-handlers.md} +7 -6
  38. data/docs/reference/serializers.md +245 -0
  39. data/docs/{transports.md → reference/transports.md} +9 -11
  40. data/docs/transports/memory-transport.md +374 -0
  41. data/docs/transports/redis-transport-comparison.md +361 -0
  42. data/docs/transports/redis-transport.md +490 -0
  43. data/examples/README.md +104 -14
  44. data/examples/city_scenario/911_emergency_call_flow.svg +99 -0
  45. data/examples/city_scenario/README.md +515 -0
  46. data/examples/city_scenario/ai_visitor_intelligence_flow.svg +108 -0
  47. data/examples/city_scenario/citizen.rb +195 -0
  48. data/examples/city_scenario/city_diagram.svg +125 -0
  49. data/examples/city_scenario/common/health_monitor.rb +80 -0
  50. data/examples/city_scenario/common/logger.rb +30 -0
  51. data/examples/city_scenario/emergency_dispatch_center.rb +270 -0
  52. data/examples/city_scenario/fire_department.rb +446 -0
  53. data/examples/city_scenario/fire_emergency_flow.svg +95 -0
  54. data/examples/city_scenario/health_department.rb +100 -0
  55. data/examples/city_scenario/health_monitoring_system.svg +130 -0
  56. data/examples/city_scenario/house.rb +244 -0
  57. data/examples/city_scenario/local_bank.rb +217 -0
  58. data/examples/city_scenario/messages/emergency_911_message.rb +80 -0
  59. data/examples/city_scenario/messages/emergency_resolved_message.rb +42 -0
  60. data/examples/city_scenario/messages/fire_dispatch_message.rb +42 -0
  61. data/examples/city_scenario/messages/fire_emergency_message.rb +44 -0
  62. data/examples/city_scenario/messages/health_check_message.rb +21 -0
  63. data/examples/city_scenario/messages/health_status_message.rb +34 -0
  64. data/examples/city_scenario/messages/police_dispatch_message.rb +45 -0
  65. data/examples/city_scenario/messages/silent_alarm_message.rb +37 -0
  66. data/examples/city_scenario/police_department.rb +316 -0
  67. data/examples/city_scenario/redis_monitor.rb +129 -0
  68. data/examples/city_scenario/redis_stats.rb +743 -0
  69. data/examples/city_scenario/room_for_improvement.md +240 -0
  70. data/examples/city_scenario/security_emergency_flow.svg +95 -0
  71. data/examples/city_scenario/service_internal_architecture.svg +154 -0
  72. data/examples/city_scenario/smart_message_ai_agent.rb +364 -0
  73. data/examples/city_scenario/start_demo.sh +236 -0
  74. data/examples/city_scenario/stop_demo.sh +106 -0
  75. data/examples/city_scenario/visitor.rb +631 -0
  76. data/examples/{10_message_deduplication.rb → memory/01_message_deduplication_demo.rb} +1 -3
  77. data/examples/{09_dead_letter_queue_demo.rb → memory/02_dead_letter_queue_demo.rb} +10 -40
  78. data/examples/{01_point_to_point_orders.rb → memory/03_point_to_point_orders.rb} +1 -3
  79. data/examples/{02_publish_subscribe_events.rb → memory/04_publish_subscribe_events.rb} +1 -2
  80. data/examples/{03_many_to_many_chat.rb → memory/05_many_to_many_chat.rb} +1 -4
  81. data/examples/{show_me.rb → memory/06_pretty_print_demo.rb} +1 -1
  82. data/examples/{05_proc_handlers.rb → memory/07_proc_handlers_demo.rb} +1 -2
  83. data/examples/{06_custom_logger_example.rb → memory/08_custom_logger_demo.rb} +13 -14
  84. data/examples/{07_error_handling_scenarios.rb → memory/09_error_handling_demo.rb} +1 -4
  85. data/examples/{08_entity_addressing_basic.rb → memory/10_entity_addressing_basic.rb} +2 -8
  86. data/examples/{08_entity_addressing_with_filtering.rb → memory/11_entity_addressing_with_filtering.rb} +2 -6
  87. data/examples/{09_regex_filtering_microservices.rb → memory/12_regex_filtering_microservices.rb} +1 -2
  88. data/examples/{10_header_block_configuration.rb → memory/13_header_block_configuration.rb} +1 -6
  89. data/examples/{11_global_configuration_example.rb → memory/14_global_configuration_demo.rb} +17 -8
  90. data/examples/{show_logger.rb → memory/15_logger_demo.rb} +1 -2
  91. data/examples/memory/README.md +163 -0
  92. data/examples/memory/memory_transport_architecture.svg +90 -0
  93. data/examples/memory/point_to_point_pattern.svg +94 -0
  94. data/examples/memory/publish_subscribe_pattern.svg +125 -0
  95. data/examples/{04_redis_smart_home_iot.rb → redis/01_smart_home_iot_demo.rb} +1 -5
  96. data/examples/redis/README.md +228 -0
  97. data/examples/redis/alert_system_flow.svg +127 -0
  98. data/examples/redis/dashboard_status_flow.svg +107 -0
  99. data/examples/redis/device_command_flow.svg +113 -0
  100. data/examples/redis/redis_transport_architecture.svg +115 -0
  101. data/examples/{smart_home_iot_dataflow.md → redis/smart_home_iot_dataflow.md} +4 -116
  102. data/examples/redis/smart_home_system_architecture.svg +133 -0
  103. data/ideas/README.md +41 -0
  104. data/ideas/agents.md +1001 -0
  105. data/ideas/database_transport.md +980 -0
  106. data/ideas/improvement.md +359 -0
  107. data/ideas/meshage.md +1788 -0
  108. data/ideas/message_discovery.md +178 -0
  109. data/ideas/message_schema.md +1381 -0
  110. data/lib/smart_message/.idea/.gitignore +8 -0
  111. data/lib/smart_message/.idea/markdown.xml +6 -0
  112. data/lib/smart_message/.idea/misc.xml +4 -0
  113. data/lib/smart_message/.idea/modules.xml +8 -0
  114. data/lib/smart_message/.idea/smart_message.iml +16 -0
  115. data/lib/smart_message/.idea/vcs.xml +6 -0
  116. data/lib/smart_message/addressing.rb +15 -0
  117. data/lib/smart_message/base.rb +19 -12
  118. data/lib/smart_message/configuration.rb +2 -23
  119. data/lib/smart_message/dead_letter_queue.rb +1 -1
  120. data/lib/smart_message/logger.rb +15 -4
  121. data/lib/smart_message/messaging.rb +3 -62
  122. data/lib/smart_message/plugins.rb +6 -44
  123. data/lib/smart_message/serializer.rb +14 -0
  124. data/lib/smart_message/transport/base.rb +42 -8
  125. data/lib/smart_message/transport/memory_transport.rb +23 -4
  126. data/lib/smart_message/transport/redis_transport.rb +11 -0
  127. data/lib/smart_message/transport/stdout_transport.rb +28 -10
  128. data/lib/smart_message/transport.rb +33 -1
  129. data/lib/smart_message/version.rb +1 -1
  130. data/lib/smart_message.rb +5 -52
  131. data/mkdocs.yml +184 -0
  132. data/p2p_plan.md +326 -0
  133. data/p2p_roadmap.md +287 -0
  134. data/smart_message.gemspec +2 -0
  135. data/smart_message.svg +51 -0
  136. metadata +145 -45
  137. data/docs/README.md +0 -57
  138. data/docs/serializers.md +0 -575
  139. data/examples/dead_letters.jsonl +0 -12
  140. data/examples/temp.txt +0 -94
  141. data/examples/tmux_chat/README.md +0 -283
  142. data/examples/tmux_chat/bot_agent.rb +0 -278
  143. data/examples/tmux_chat/human_agent.rb +0 -199
  144. data/examples/tmux_chat/room_monitor.rb +0 -160
  145. data/examples/tmux_chat/shared_chat_system.rb +0 -328
  146. data/examples/tmux_chat/start_chat_demo.sh +0 -190
  147. data/examples/tmux_chat/stop_chat_demo.sh +0 -22
  148. /data/docs/{properties.md → core-concepts/properties.md} +0 -0
  149. /data/docs/{ideas_to_think_about.md → development/ideas.md} +0 -0
@@ -20,12 +20,10 @@ class NotificationMessage < SmartMessage::Base
20
20
 
21
21
  config do
22
22
  transport SmartMessage::Transport.create(:stdout, loopback: true)
23
- serializer SmartMessage::Serializer::JSON.new
24
23
  end
25
24
 
26
- def self.process(message_header, message_payload)
27
- data = JSON.parse(message_payload)
28
- notification = new(data)
25
+ def self.process(decoded_message)
26
+ notification = decoded_message
29
27
 
30
28
  case notification.channel
31
29
  when 'email'
@@ -88,12 +86,10 @@ class UserRegisteredEvent < SmartMessage::Base
88
86
 
89
87
  config do
90
88
  transport SmartMessage::Transport.create(:memory, auto_process: true)
91
- serializer SmartMessage::Serializer::JSON.new
92
89
  end
93
90
 
94
- def self.process(message_header, message_payload)
95
- data = JSON.parse(message_payload)
96
- event = new(data)
91
+ def self.process(decoded_message)
92
+ event = decoded_message
97
93
 
98
94
  # Fan out to multiple handlers
99
95
  send_welcome_email(event)
@@ -154,12 +150,11 @@ class WelcomeEmailMessage < SmartMessage::Base
154
150
 
155
151
  config do
156
152
  transport SmartMessage::Transport.create(:stdout)
157
- serializer SmartMessage::Serializer::JSON.new
158
153
  end
159
154
 
160
- def self.process(message_header, message_payload)
161
- data = JSON.parse(message_payload)
162
- message = new(data)
155
+ def self.process(decoded_message)
156
+ # decoded_message is already a message instance
157
+ message = decoded_message
163
158
 
164
159
  puts "📧 Sending welcome email to #{message.email} (#{message.name})"
165
160
  # Email sending logic here
@@ -173,12 +168,11 @@ class AnalyticsMessage < SmartMessage::Base
173
168
 
174
169
  config do
175
170
  transport SmartMessage::Transport.create(:stdout)
176
- serializer SmartMessage::Serializer::JSON.new
177
171
  end
178
172
 
179
- def self.process(message_header, message_payload)
180
- data = JSON.parse(message_payload)
181
- event = new(data)
173
+ def self.process(decoded_message)
174
+ # decoded_message is already a message instance
175
+ event = decoded_message
182
176
 
183
177
  puts "📊 Tracking event: #{event.event_type} for user #{event.user_id}"
184
178
  # Analytics tracking logic here
@@ -211,12 +205,11 @@ class OrderCreatedMessage < SmartMessage::Base
211
205
 
212
206
  config do
213
207
  transport SmartMessage::Transport.create(:memory, auto_process: true)
214
- serializer SmartMessage::Serializer::JSON.new
215
208
  end
216
209
 
217
- def self.process(message_header, message_payload)
218
- data = JSON.parse(message_payload)
219
- order = new(data)
210
+ def self.process(decoded_message)
211
+ # decoded_message is already a message instance
212
+ order = decoded_message
220
213
 
221
214
  # Validate order
222
215
  if valid_order?(order)
@@ -254,12 +247,11 @@ class InventoryReservationMessage < SmartMessage::Base
254
247
 
255
248
  config do
256
249
  transport SmartMessage::Transport.create(:memory, auto_process: true)
257
- serializer SmartMessage::Serializer::JSON.new
258
250
  end
259
251
 
260
- def self.process(message_header, message_payload)
261
- data = JSON.parse(message_payload)
262
- reservation = new(data)
252
+ def self.process(decoded_message)
253
+ # decoded_message is already a message instance
254
+ reservation = decoded_message
263
255
 
264
256
  success = reserve_inventory(reservation.items)
265
257
 
@@ -291,12 +283,11 @@ class PaymentProcessingMessage < SmartMessage::Base
291
283
 
292
284
  config do
293
285
  transport SmartMessage::Transport.create(:memory, auto_process: true)
294
- serializer SmartMessage::Serializer::JSON.new
295
286
  end
296
287
 
297
- def self.process(message_header, message_payload)
298
- data = JSON.parse(message_payload)
299
- payment = new(data)
288
+ def self.process(decoded_message)
289
+ # decoded_message is already a message instance
290
+ payment = decoded_message
300
291
 
301
292
  success = process_payment(payment)
302
293
 
@@ -364,12 +355,11 @@ class LogMessage < SmartMessage::Base
364
355
 
365
356
  config do
366
357
  transport SmartMessage::Transport.create(:stdout, output: "application.log")
367
- serializer SmartMessage::Serializer::JSON.new
368
358
  end
369
359
 
370
- def self.process(message_header, message_payload)
371
- data = JSON.parse(message_payload)
372
- log_entry = new(data)
360
+ def self.process(decoded_message)
361
+ # decoded_message is already a message instance
362
+ log_entry = decoded_message
373
363
 
374
364
  formatted_message = format_log_entry(log_entry)
375
365
 
@@ -414,12 +404,11 @@ class MetricMessage < SmartMessage::Base
414
404
 
415
405
  config do
416
406
  transport SmartMessage::Transport.create(:memory, auto_process: true)
417
- serializer SmartMessage::Serializer::JSON.new
418
407
  end
419
408
 
420
- def self.process(message_header, message_payload)
421
- data = JSON.parse(message_payload)
422
- metric = new(data)
409
+ def self.process(decoded_message)
410
+ # decoded_message is already a message instance
411
+ metric = decoded_message
423
412
 
424
413
  # Store metric (would typically go to monitoring system)
425
414
  store_metric(metric)
@@ -498,12 +487,11 @@ class MessageGateway < SmartMessage::Base
498
487
  # Receive from one transport
499
488
  config do
500
489
  transport SmartMessage::Transport.create(:memory, auto_process: true)
501
- serializer SmartMessage::Serializer::JSON.new
502
490
  end
503
491
 
504
- def self.process(message_header, message_payload)
505
- data = JSON.parse(message_payload)
506
- gateway_message = new(data)
492
+ def self.process(decoded_message)
493
+ # decoded_message is already a message instance
494
+ gateway_message = decoded_message
507
495
 
508
496
  # Transform and forward to destination system
509
497
  case gateway_message.destination_system
@@ -567,8 +555,8 @@ class EmailSystemMessage < SmartMessage::Base
567
555
  property :original_payload
568
556
  property :source
569
557
 
570
- def self.process(message_header, message_payload)
571
- puts "📧 Email system processed message from #{JSON.parse(message_payload)['source']}"
558
+ def self.process(decoded_message)
559
+ puts "📧 Email system processed message from #{decoded_message.source}"
572
560
  end
573
561
  end
574
562
 
@@ -576,8 +564,8 @@ class SMSSystemMessage < SmartMessage::Base
576
564
  property :original_payload
577
565
  property :source
578
566
 
579
- def self.process(message_header, message_payload)
580
- puts "📱 SMS system processed message from #{JSON.parse(message_payload)['source']}"
567
+ def self.process(decoded_message)
568
+ puts "📱 SMS system processed message from #{decoded_message.source}"
581
569
  end
582
570
  end
583
571
 
@@ -587,8 +575,8 @@ class AuditSystemMessage < SmartMessage::Base
587
575
  property :source_system
588
576
  property :processed_at
589
577
 
590
- def self.process(message_header, message_payload)
591
- puts "📋 Audit system logged event from #{JSON.parse(message_payload)['source_system']}"
578
+ def self.process(decoded_message)
579
+ puts "📋 Audit system logged event from #{decoded_message.source_system}"
592
580
  end
593
581
  end
594
582
 
@@ -623,12 +611,11 @@ class ResilientMessage < SmartMessage::Base
623
611
 
624
612
  config do
625
613
  transport SmartMessage::Transport.create(:memory, auto_process: true)
626
- serializer SmartMessage::Serializer::JSON.new
627
614
  end
628
615
 
629
- def self.process(message_header, message_payload)
630
- data = JSON.parse(message_payload)
631
- message = new(data)
616
+ def self.process(decoded_message)
617
+ # decoded_message is already a message instance
618
+ message = decoded_message
632
619
 
633
620
  begin
634
621
  # Simulate potentially failing operation
@@ -691,12 +678,11 @@ class DeadLetterMessage < SmartMessage::Base
691
678
 
692
679
  config do
693
680
  transport SmartMessage::Transport.create(:stdout, output: "dead_letter_queue.log")
694
- serializer SmartMessage::Serializer::JSON.new
695
681
  end
696
682
 
697
- def self.process(message_header, message_payload)
698
- data = JSON.parse(message_payload)
699
- dead_letter = new(data)
683
+ def self.process(decoded_message)
684
+ # decoded_message is already a message instance
685
+ dead_letter = decoded_message
700
686
 
701
687
  puts "💀 Message sent to dead letter queue:"
702
688
  puts " Original: #{dead_letter.original_message}"
@@ -796,9 +782,9 @@ end
796
782
  class TestMessage < SmartMessage::Base
797
783
  property :data
798
784
 
799
- def self.process(message_header, message_payload)
800
- data = JSON.parse(message_payload)
801
- message = new(data)
785
+ def self.process(decoded_message)
786
+ # decoded_message is already a message instance
787
+ message = decoded_message
802
788
  puts "Processed test message: #{message.data}"
803
789
  end
804
790
  end
@@ -813,22 +799,46 @@ These examples demonstrate the flexibility and power of SmartMessage for buildin
813
799
 
814
800
  The `examples/` directory contains complete, runnable programs that demonstrate various SmartMessage features:
815
801
 
816
- ### Core Messaging Patterns
817
- - **`01_point_to_point_orders.rb`** - Point-to-point order processing with payment integration
818
- - **`02_publish_subscribe_events.rb`** - Event broadcasting to multiple services (email, SMS, audit)
819
- - **`03_many_to_many_chat.rb`** - Interactive chat system with rooms, bots, and human agents
820
-
821
- ### Advanced Features
822
- - **`04_redis_smart_home_iot.rb`** - Redis-based IoT sensor monitoring with real-time data flow
823
- - **`05_proc_handlers.rb`** - Flexible message handlers (blocks, procs, lambdas, methods)
824
- - **`06_custom_logger_example.rb`** - Advanced logging with SmartMessage::Logger::Default
825
- - **`07_error_handling_scenarios.rb`** - Comprehensive validation, version mismatch, and error handling
826
- - **`08_entity_addressing_basic.rb`** - Basic FROM/TO/REPLY_TO message addressing
827
- - **`08_entity_addressing_with_filtering.rb`** - Advanced entity-aware message filtering
828
- - **`09_dead_letter_queue_demo.rb`** - Complete Dead Letter Queue system demonstration
829
-
830
- ### Interactive Demos
831
- - **`tmux_chat/`** - Multi-pane terminal visualization of many-to-many messaging with file-based transport
802
+ ### Memory Transport Examples
803
+ - **`memory/03_point_to_point_orders.rb`** - Point-to-point order processing with payment integration
804
+ - **`memory/04_publish_subscribe_events.rb`** - Event broadcasting to multiple services (email, SMS, audit)
805
+ - **`memory/05_many_to_many_chat.rb`** - Interactive chat system with rooms, bots, and human agents
806
+ - **`memory/07_proc_handlers_demo.rb`** - Flexible message handlers (blocks, procs, lambdas, methods)
807
+ - **`memory/08_custom_logger_demo.rb`** - Advanced logging with SmartMessage::Logger::Default
808
+ - **`memory/09_error_handling_demo.rb`** - Comprehensive validation, version mismatch, and error handling
809
+ - **`memory/10_entity_addressing_basic.rb`** - Basic FROM/TO/REPLY_TO message addressing
810
+ - **`memory/11_entity_addressing_with_filtering.rb`** - Advanced entity-aware message filtering
811
+ - **`memory/02_dead_letter_queue_demo.rb`** - Complete Dead Letter Queue system demonstration
812
+ - **`memory/01_message_deduplication_demo.rb`** - Message deduplication patterns
813
+ - **`memory/12_regex_filtering_microservices.rb`** - Advanced regex filtering for microservices
814
+ - **`memory/13_header_block_configuration.rb`** - Header and block configuration examples
815
+ - **`memory/14_global_configuration_demo.rb`** - Global configuration management
816
+ - **`memory/15_logger_demo.rb`** - Advanced logging demonstrations
817
+
818
+ ### Redis Transport Examples
819
+ - **`redis/01_smart_home_iot_demo.rb`** - Redis-based IoT sensor monitoring with real-time data flow
820
+
821
+ ### Redis Enhanced Transport Examples
822
+ - **`redis_enhanced/enhanced_01_basic_patterns.rb`** - Basic enhanced transport patterns
823
+ - **`redis_enhanced/enhanced_02_fluent_api.rb`** - Fluent API usage examples
824
+ - **`redis_enhanced/enhanced_03_dual_publishing.rb`** - Dual publishing strategies
825
+ - **`redis_enhanced/enhanced_04_advanced_routing.rb`** - Advanced message routing
826
+
827
+ ### Redis Queue Transport Examples
828
+ - **`redis_queue/01_basic_messaging.rb`** - Basic queue messaging patterns
829
+ - **`redis_queue/02_pattern_routing.rb`** - Pattern-based message routing
830
+ - **`redis_queue/03_fluent_api.rb`** - Fluent API for queue operations
831
+ - **`redis_queue/04_load_balancing.rb`** - Load balancing across workers
832
+ - **`redis_queue/05_microservices.rb`** - Microservices communication
833
+ - **`redis_queue/06_emergency_alerts.rb`** - Emergency alert system
834
+ - **`redis_queue/07_queue_management.rb`** - Queue management utilities
835
+ - **`redis_queue/01_comprehensive_examples.rb`** - Comprehensive feature demonstration
836
+
837
+ ### City Scenario (Comprehensive Demo)
838
+ - **`city_scenario/`** - Complete emergency services simulation with multiple services and AI integration
839
+
840
+ ### Performance Testing
841
+ - **`performance_metrics/`** - Benchmarking tools and performance comparisons
832
842
 
833
843
  ### Running Examples
834
844
 
@@ -836,12 +846,14 @@ The `examples/` directory contains complete, runnable programs that demonstrate
836
846
  # Navigate to the SmartMessage directory
837
847
  cd smart_message
838
848
 
839
- # Run any example directly
840
- ruby examples/01_point_to_point_orders.rb
841
- ruby examples/09_dead_letter_queue_demo.rb
849
+ # Run examples from their respective transport directories
850
+ ruby examples/memory/03_point_to_point_orders.rb
851
+ ruby examples/memory/02_dead_letter_queue_demo.rb
852
+ ruby examples/redis/01_smart_home_iot_demo.rb
853
+ ruby examples/redis_queue/01_basic_messaging.rb
842
854
 
843
- # For tmux chat demo
844
- cd examples/tmux_chat && ./run_demo.sh
855
+ # For city scenario comprehensive demo
856
+ cd examples/city_scenario && ./start_demo.sh
845
857
  ```
846
858
 
847
859
  Each example is self-contained and includes:
@@ -853,16 +865,18 @@ Each example is self-contained and includes:
853
865
 
854
866
  ### Example Features Demonstrated
855
867
 
856
- | Example | Transports | Features | Use Case |
857
- |---------|------------|----------|----------|
858
- | 01 | STDOUT | Point-to-point, validation | Order processing |
859
- | 02 | STDOUT | Pub-sub, multiple handlers | Event broadcasting |
860
- | 03 | Memory | Many-to-many, bots | Chat systems |
861
- | 04 | Redis | IoT, real-time, addressing | Smart home monitoring |
862
- | 05 | Memory | Proc handlers, flexibility | Dynamic message handling |
863
- | 06 | STDOUT | Custom logging, lifecycle | Production logging |
864
- | 07 | STDOUT | Error handling, validation | Robust message systems |
865
- | 08 | STDOUT | Entity addressing, filtering | Microservice communication |
866
- | 09 | Memory | DLQ, circuit breakers, replay | Production reliability |
868
+ | Example | Transport | Features | Use Case |
869
+ |---------|-----------|----------|----------|
870
+ | memory/03 | Memory/STDOUT | Point-to-point, validation | Order processing |
871
+ | memory/04 | Memory/STDOUT | Pub-sub, multiple handlers | Event broadcasting |
872
+ | memory/05 | Memory | Many-to-many, bots | Chat systems |
873
+ | redis/01 | Redis | IoT, real-time, addressing | Smart home monitoring |
874
+ | memory/07 | Memory | Proc handlers, flexibility | Dynamic message handling |
875
+ | memory/08 | Memory/STDOUT | Custom logging, lifecycle | Production logging |
876
+ | memory/09 | Memory/STDOUT | Error handling, validation | Robust message systems |
877
+ | memory/10-11 | Memory/STDOUT | Entity addressing, filtering | Microservice communication |
878
+ | memory/02 | Memory | DLQ, circuit breakers, replay | Production reliability |
879
+ | redis_queue/* | Redis Queue | Load balancing, persistence | Production messaging |
880
+ | city_scenario/* | Redis | AI integration, health monitoring | Emergency services |
867
881
 
868
882
  These examples provide practical, working code that you can use as a starting point for your own SmartMessage implementations.
@@ -1,3 +1,4 @@
1
+
1
2
  # Getting Started with SmartMessage
2
3
 
3
4
  This guide will help you get up and running with SmartMessage quickly.
@@ -25,7 +26,38 @@ gem install smart_message
25
26
  ## Requirements
26
27
 
27
28
  - Ruby >= 3.0.0
28
- - No additional system dependencies
29
+ - No additional system dependencies for basic usage
30
+
31
+ ## Transport Options
32
+
33
+ SmartMessage supports multiple transport layers:
34
+
35
+ ### Built-in Transports
36
+
37
+ - **Memory Transport** - Perfect for development and testing. No external dependencies required.
38
+ - **STDOUT Transport** - Great for debugging and logging. No external dependencies.
39
+ - **Redis Transport** - Production-ready transport for distributed systems. Requires Redis server.
40
+
41
+ ### Redis Installation (Optional)
42
+
43
+ The Redis transport is built-in but requires Redis server to be installed. However, **you don't need Redis just to play around** - the Memory transport works great for development and testing.
44
+
45
+ If you want to use Redis transport:
46
+
47
+ **macOS:**
48
+ ```bash
49
+ brew install redis
50
+ brew services start redis
51
+ ```
52
+
53
+ **Ubuntu/Debian:**
54
+ ```bash
55
+ sudo apt-get update
56
+ sudo apt-get install redis-server
57
+ ```
58
+
59
+ **Other Transports:**
60
+ Additional transport layers (RabbitMQ, Kafka, etc.) are available as separate plugin repositories. Check the [Transports documentation](../reference/transports.md) for more information.
29
61
 
30
62
  ## Your First Message
31
63
 
@@ -60,14 +92,12 @@ class WelcomeMessage < SmartMessage::Base
60
92
  # Configure the transport (where messages go)
61
93
  config do
62
94
  transport SmartMessage::Transport.create(:stdout, loopback: true)
63
- serializer SmartMessage::Serializer::JSON.new
64
95
  end
65
96
 
66
97
  # Define how to process received messages
67
- def self.process(message_header, message_payload)
68
- # Decode the message
69
- data = JSON.parse(message_payload)
70
- welcome = new(data)
98
+ def self.process(decoded_message)
99
+ # decoded_message is already a message instance
100
+ welcome = decoded_message
71
101
 
72
102
  # Process the welcome message
73
103
  puts "🎉 Welcome #{welcome.user_name}!"
@@ -182,12 +212,10 @@ transport SmartMessage::Transport.create(:memory, auto_process: true)
182
212
  ```
183
213
 
184
214
  ### Serializers
185
- Serializers handle message encoding/decoding:
186
-
187
- ```ruby
188
- # JSON serialization (built-in)
189
- serializer SmartMessage::Serializer::JSON.new
190
- ```
215
+ Transports handle their own serialization automatically:
216
+ - **MemoryTransport**: No serialization (objects passed directly)
217
+ - **StdoutTransport**: JSON serialization for readability
218
+ - **RedisTransport**: MessagePack (with JSON fallback) for efficiency
191
219
 
192
220
  ### Message Handlers
193
221
 
@@ -265,16 +293,15 @@ payment.to('backup-gateway') # Override destination
265
293
  payment.publish
266
294
  ```
267
295
 
268
- For more details, see [Entity Addressing](addressing.md).
296
+ For more details, see [Entity Addressing](../core-concepts/addressing.md).
269
297
 
270
298
  ## Next Steps
271
299
 
272
300
  Now that you have the basics working, explore:
273
301
 
274
- - [Architecture Overview](architecture.md) - Understand how SmartMessage works
302
+ - [Architecture Overview](../core-concepts/architecture.md) - Understand how SmartMessage works
275
303
  - [Examples](examples.md) - See more practical use cases
276
- - [Transports](transports.md) - Learn about different transport options
277
- - [Custom Transports](custom-transports.md) - Build your own transport
304
+ - [Transports](../reference/transports.md) - Learn about different transport options
278
305
 
279
306
  ## Common Patterns
280
307
 
@@ -291,12 +318,11 @@ class NotificationMessage < SmartMessage::Base
291
318
 
292
319
  config do
293
320
  transport SmartMessage::Transport.create(:memory, auto_process: true)
294
- serializer SmartMessage::Serializer::JSON.new
295
321
  end
296
322
 
297
- def self.process(message_header, message_payload)
298
- data = JSON.parse(message_payload)
299
- notification = new(data)
323
+ def self.process(decoded_message)
324
+ # decoded_message is already a message instance
325
+ notification = decoded_message
300
326
 
301
327
  # Send email, SMS, push notification, etc.
302
328
  send_notification(notification)
@@ -334,7 +360,6 @@ class EventMessage < SmartMessage::Base
334
360
 
335
361
  config do
336
362
  transport SmartMessage::Transport.create(:stdout, output: 'events.log')
337
- serializer SmartMessage::Serializer::JSON.new
338
363
  end
339
364
  end
340
365
 
@@ -348,6 +373,5 @@ EventMessage.new(
348
373
 
349
374
  ## Need Help?
350
375
 
351
- - Check the [Troubleshooting Guide](troubleshooting.md)
352
- - Review the [API Reference](api-reference.md)
376
+ - Check the [Troubleshooting Guide](../development/troubleshooting.md)
353
377
  - Look at more [Examples](examples.md)
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 Transport](transports/redis-transport.md)
35
+ - [Redis Transport Comparison](transports/redis-transport-comparison.md)
36
+
37
+ ### Guides
38
+ - [Examples & Use Cases](getting-started/examples.md)
39
+ - [Architecture Overview](core-concepts/architecture.md)
40
+ - [Transport Configuration](reference/transports.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.