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.
- checksums.yaml +4 -4
- data/.github/workflows/deploy-github-pages.yml +38 -0
- data/.gitignore +5 -0
- data/CHANGELOG.md +30 -0
- data/Gemfile.lock +35 -4
- data/README.md +169 -71
- data/Rakefile +29 -4
- data/docs/assets/images/ddq_architecture.svg +130 -0
- data/docs/assets/images/dlq_architecture.svg +115 -0
- data/docs/assets/images/enhanced-dual-publishing.svg +136 -0
- data/docs/assets/images/enhanced-fluent-api.svg +149 -0
- data/docs/assets/images/enhanced-microservices-routing.svg +115 -0
- data/docs/assets/images/enhanced-pattern-matching.svg +107 -0
- data/docs/assets/images/fluent-api-demo.svg +59 -0
- data/docs/assets/images/performance-comparison.svg +161 -0
- data/docs/assets/images/redis-basic-architecture.svg +53 -0
- data/docs/assets/images/redis-enhanced-architecture.svg +88 -0
- data/docs/assets/images/redis-queue-architecture.svg +101 -0
- data/docs/assets/images/smart_message.jpg +0 -0
- data/docs/assets/images/smart_message_walking.jpg +0 -0
- data/docs/assets/images/smartmessage_architecture_overview.svg +173 -0
- data/docs/assets/images/transport-comparison-matrix.svg +171 -0
- data/docs/assets/javascripts/mathjax.js +17 -0
- data/docs/assets/stylesheets/extra.css +51 -0
- data/docs/{addressing.md → core-concepts/addressing.md} +5 -7
- data/docs/{architecture.md → core-concepts/architecture.md} +78 -138
- data/docs/{dispatcher.md → core-concepts/dispatcher.md} +21 -21
- data/docs/{message_filtering.md → core-concepts/message-filtering.md} +2 -3
- data/docs/{message_processing.md → core-concepts/message-processing.md} +17 -17
- data/docs/{troubleshooting.md → development/troubleshooting.md} +7 -7
- data/docs/{examples.md → getting-started/examples.md} +115 -89
- data/docs/{getting-started.md → getting-started/quick-start.md} +47 -18
- data/docs/guides/redis-queue-getting-started.md +697 -0
- data/docs/guides/redis-queue-patterns.md +889 -0
- data/docs/guides/redis-queue-production.md +1091 -0
- data/docs/index.md +64 -0
- data/docs/{dead_letter_queue.md → reference/dead-letter-queue.md} +2 -3
- data/docs/{logging.md → reference/logging.md} +1 -1
- data/docs/{message_deduplication.md → reference/message-deduplication.md} +1 -0
- data/docs/{proc_handlers_summary.md → reference/proc-handlers.md} +7 -6
- data/docs/{serializers.md → reference/serializers.md} +3 -5
- data/docs/{transports.md → reference/transports.md} +133 -11
- data/docs/transports/memory-transport.md +374 -0
- data/docs/transports/redis-enhanced-transport.md +524 -0
- data/docs/transports/redis-queue-transport.md +1304 -0
- data/docs/transports/redis-transport-comparison.md +496 -0
- data/docs/transports/redis-transport.md +509 -0
- data/examples/README.md +98 -5
- data/examples/city_scenario/911_emergency_call_flow.svg +99 -0
- data/examples/city_scenario/README.md +515 -0
- data/examples/city_scenario/ai_visitor_intelligence_flow.svg +108 -0
- data/examples/city_scenario/citizen.rb +195 -0
- data/examples/city_scenario/city_diagram.svg +125 -0
- data/examples/city_scenario/common/health_monitor.rb +80 -0
- data/examples/city_scenario/common/logger.rb +30 -0
- data/examples/city_scenario/emergency_dispatch_center.rb +270 -0
- data/examples/city_scenario/fire_department.rb +446 -0
- data/examples/city_scenario/fire_emergency_flow.svg +95 -0
- data/examples/city_scenario/health_department.rb +100 -0
- data/examples/city_scenario/health_monitoring_system.svg +130 -0
- data/examples/city_scenario/house.rb +244 -0
- data/examples/city_scenario/local_bank.rb +217 -0
- data/examples/city_scenario/messages/emergency_911_message.rb +81 -0
- data/examples/city_scenario/messages/emergency_resolved_message.rb +43 -0
- data/examples/city_scenario/messages/fire_dispatch_message.rb +43 -0
- data/examples/city_scenario/messages/fire_emergency_message.rb +45 -0
- data/examples/city_scenario/messages/health_check_message.rb +22 -0
- data/examples/city_scenario/messages/health_status_message.rb +35 -0
- data/examples/city_scenario/messages/police_dispatch_message.rb +46 -0
- data/examples/city_scenario/messages/silent_alarm_message.rb +38 -0
- data/examples/city_scenario/police_department.rb +316 -0
- data/examples/city_scenario/redis_monitor.rb +129 -0
- data/examples/city_scenario/redis_stats.rb +743 -0
- data/examples/city_scenario/room_for_improvement.md +240 -0
- data/examples/city_scenario/security_emergency_flow.svg +95 -0
- data/examples/city_scenario/service_internal_architecture.svg +154 -0
- data/examples/city_scenario/smart_message_ai_agent.rb +364 -0
- data/examples/city_scenario/start_demo.sh +236 -0
- data/examples/city_scenario/stop_demo.sh +106 -0
- data/examples/city_scenario/visitor.rb +631 -0
- data/examples/{10_message_deduplication.rb → memory/01_message_deduplication_demo.rb} +1 -1
- data/examples/{09_dead_letter_queue_demo.rb → memory/02_dead_letter_queue_demo.rb} +13 -40
- data/examples/{01_point_to_point_orders.rb → memory/03_point_to_point_orders.rb} +1 -1
- data/examples/{02_publish_subscribe_events.rb → memory/04_publish_subscribe_events.rb} +2 -2
- data/examples/{03_many_to_many_chat.rb → memory/05_many_to_many_chat.rb} +4 -4
- data/examples/{show_me.rb → memory/06_pretty_print_demo.rb} +1 -1
- data/examples/{05_proc_handlers.rb → memory/07_proc_handlers_demo.rb} +2 -2
- data/examples/{06_custom_logger_example.rb → memory/08_custom_logger_demo.rb} +17 -14
- data/examples/{07_error_handling_scenarios.rb → memory/09_error_handling_demo.rb} +4 -4
- data/examples/{08_entity_addressing_basic.rb → memory/10_entity_addressing_basic.rb} +8 -8
- data/examples/{08_entity_addressing_with_filtering.rb → memory/11_entity_addressing_with_filtering.rb} +6 -6
- data/examples/{09_regex_filtering_microservices.rb → memory/12_regex_filtering_microservices.rb} +2 -2
- data/examples/{10_header_block_configuration.rb → memory/13_header_block_configuration.rb} +6 -6
- data/examples/{11_global_configuration_example.rb → memory/14_global_configuration_demo.rb} +19 -8
- data/examples/{show_logger.rb → memory/15_logger_demo.rb} +1 -1
- data/examples/memory/README.md +163 -0
- data/examples/memory/memory_transport_architecture.svg +90 -0
- data/examples/memory/point_to_point_pattern.svg +94 -0
- data/examples/memory/publish_subscribe_pattern.svg +125 -0
- data/examples/{04_redis_smart_home_iot.rb → redis/01_smart_home_iot_demo.rb} +5 -5
- data/examples/redis/README.md +230 -0
- data/examples/redis/alert_system_flow.svg +127 -0
- data/examples/redis/dashboard_status_flow.svg +107 -0
- data/examples/redis/device_command_flow.svg +113 -0
- data/examples/redis/redis_transport_architecture.svg +115 -0
- data/examples/{smart_home_iot_dataflow.md → redis/smart_home_iot_dataflow.md} +4 -116
- data/examples/redis/smart_home_system_architecture.svg +133 -0
- data/examples/redis_enhanced/README.md +319 -0
- data/examples/redis_enhanced/enhanced_01_basic_patterns.rb +233 -0
- data/examples/redis_enhanced/enhanced_02_fluent_api.rb +331 -0
- data/examples/redis_enhanced/enhanced_03_dual_publishing.rb +281 -0
- data/examples/redis_enhanced/enhanced_04_advanced_routing.rb +419 -0
- data/examples/redis_queue/01_basic_messaging.rb +221 -0
- data/examples/redis_queue/01_comprehensive_examples.rb +508 -0
- data/examples/redis_queue/02_pattern_routing.rb +405 -0
- data/examples/redis_queue/03_fluent_api.rb +422 -0
- data/examples/redis_queue/04_load_balancing.rb +486 -0
- data/examples/redis_queue/05_microservices.rb +735 -0
- data/examples/redis_queue/06_emergency_alerts.rb +777 -0
- data/examples/redis_queue/07_queue_management.rb +587 -0
- data/examples/redis_queue/README.md +366 -0
- data/examples/redis_queue/enhanced_01_basic_patterns.rb +233 -0
- data/examples/redis_queue/enhanced_02_fluent_api.rb +331 -0
- data/examples/redis_queue/enhanced_03_dual_publishing.rb +281 -0
- data/examples/redis_queue/enhanced_04_advanced_routing.rb +419 -0
- data/examples/redis_queue/redis_queue_architecture.svg +148 -0
- data/ideas/README.md +41 -0
- data/ideas/agents.md +1001 -0
- data/ideas/database_transport.md +980 -0
- data/ideas/improvement.md +359 -0
- data/ideas/meshage.md +1788 -0
- data/ideas/message_discovery.md +178 -0
- data/ideas/message_schema.md +1381 -0
- data/lib/smart_message/.idea/.gitignore +8 -0
- data/lib/smart_message/.idea/markdown.xml +6 -0
- data/lib/smart_message/.idea/misc.xml +4 -0
- data/lib/smart_message/.idea/modules.xml +8 -0
- data/lib/smart_message/.idea/smart_message.iml +16 -0
- data/lib/smart_message/.idea/vcs.xml +6 -0
- data/lib/smart_message/addressing.rb +15 -0
- data/lib/smart_message/base.rb +0 -2
- data/lib/smart_message/configuration.rb +1 -1
- data/lib/smart_message/logger.rb +15 -4
- data/lib/smart_message/plugins.rb +5 -2
- data/lib/smart_message/serializer.rb +14 -0
- data/lib/smart_message/transport/redis_enhanced_transport.rb +399 -0
- data/lib/smart_message/transport/redis_queue_transport.rb +555 -0
- data/lib/smart_message/transport/registry.rb +1 -0
- data/lib/smart_message/transport.rb +34 -1
- data/lib/smart_message/version.rb +1 -1
- data/lib/smart_message.rb +5 -52
- data/mkdocs.yml +184 -0
- data/p2p_plan.md +326 -0
- data/p2p_roadmap.md +287 -0
- data/smart_message.gemspec +2 -0
- data/smart_message.svg +51 -0
- metadata +170 -44
- data/docs/README.md +0 -57
- data/examples/dead_letters.jsonl +0 -12
- data/examples/temp.txt +0 -94
- data/examples/tmux_chat/README.md +0 -283
- data/examples/tmux_chat/bot_agent.rb +0 -278
- data/examples/tmux_chat/human_agent.rb +0 -199
- data/examples/tmux_chat/room_monitor.rb +0 -160
- data/examples/tmux_chat/shared_chat_system.rb +0 -328
- data/examples/tmux_chat/start_chat_demo.sh +0 -190
- data/examples/tmux_chat/stop_chat_demo.sh +0 -22
- /data/docs/{properties.md → core-concepts/properties.md} +0 -0
- /data/docs/{ideas_to_think_about.md → development/ideas.md} +0 -0
@@ -20,12 +20,11 @@ class NotificationMessage < SmartMessage::Base
|
|
20
20
|
|
21
21
|
config do
|
22
22
|
transport SmartMessage::Transport.create(:stdout, loopback: true)
|
23
|
-
serializer SmartMessage::Serializer::
|
23
|
+
serializer SmartMessage::Serializer::Json.new
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.process(
|
27
|
-
|
28
|
-
notification = new(data)
|
26
|
+
def self.process(decoded_message)
|
27
|
+
notification = decoded_message
|
29
28
|
|
30
29
|
case notification.channel
|
31
30
|
when 'email'
|
@@ -88,12 +87,11 @@ class UserRegisteredEvent < SmartMessage::Base
|
|
88
87
|
|
89
88
|
config do
|
90
89
|
transport SmartMessage::Transport.create(:memory, auto_process: true)
|
91
|
-
serializer SmartMessage::Serializer::
|
90
|
+
serializer SmartMessage::Serializer::Json.new
|
92
91
|
end
|
93
92
|
|
94
|
-
def self.process(
|
95
|
-
|
96
|
-
event = new(data)
|
93
|
+
def self.process(decoded_message)
|
94
|
+
event = decoded_message
|
97
95
|
|
98
96
|
# Fan out to multiple handlers
|
99
97
|
send_welcome_email(event)
|
@@ -154,12 +152,12 @@ class WelcomeEmailMessage < SmartMessage::Base
|
|
154
152
|
|
155
153
|
config do
|
156
154
|
transport SmartMessage::Transport.create(:stdout)
|
157
|
-
serializer SmartMessage::Serializer::
|
155
|
+
serializer SmartMessage::Serializer::Json.new
|
158
156
|
end
|
159
157
|
|
160
|
-
def self.process(
|
161
|
-
|
162
|
-
message =
|
158
|
+
def self.process(decoded_message)
|
159
|
+
# decoded_message is already a message instance
|
160
|
+
message = decoded_message
|
163
161
|
|
164
162
|
puts "📧 Sending welcome email to #{message.email} (#{message.name})"
|
165
163
|
# Email sending logic here
|
@@ -173,12 +171,12 @@ class AnalyticsMessage < SmartMessage::Base
|
|
173
171
|
|
174
172
|
config do
|
175
173
|
transport SmartMessage::Transport.create(:stdout)
|
176
|
-
serializer SmartMessage::Serializer::
|
174
|
+
serializer SmartMessage::Serializer::Json.new
|
177
175
|
end
|
178
176
|
|
179
|
-
def self.process(
|
180
|
-
|
181
|
-
event =
|
177
|
+
def self.process(decoded_message)
|
178
|
+
# decoded_message is already a message instance
|
179
|
+
event = decoded_message
|
182
180
|
|
183
181
|
puts "📊 Tracking event: #{event.event_type} for user #{event.user_id}"
|
184
182
|
# Analytics tracking logic here
|
@@ -211,12 +209,12 @@ class OrderCreatedMessage < SmartMessage::Base
|
|
211
209
|
|
212
210
|
config do
|
213
211
|
transport SmartMessage::Transport.create(:memory, auto_process: true)
|
214
|
-
serializer SmartMessage::Serializer::
|
212
|
+
serializer SmartMessage::Serializer::Json.new
|
215
213
|
end
|
216
214
|
|
217
|
-
def self.process(
|
218
|
-
|
219
|
-
order =
|
215
|
+
def self.process(decoded_message)
|
216
|
+
# decoded_message is already a message instance
|
217
|
+
order = decoded_message
|
220
218
|
|
221
219
|
# Validate order
|
222
220
|
if valid_order?(order)
|
@@ -254,12 +252,12 @@ class InventoryReservationMessage < SmartMessage::Base
|
|
254
252
|
|
255
253
|
config do
|
256
254
|
transport SmartMessage::Transport.create(:memory, auto_process: true)
|
257
|
-
serializer SmartMessage::Serializer::
|
255
|
+
serializer SmartMessage::Serializer::Json.new
|
258
256
|
end
|
259
257
|
|
260
|
-
def self.process(
|
261
|
-
|
262
|
-
reservation =
|
258
|
+
def self.process(decoded_message)
|
259
|
+
# decoded_message is already a message instance
|
260
|
+
reservation = decoded_message
|
263
261
|
|
264
262
|
success = reserve_inventory(reservation.items)
|
265
263
|
|
@@ -291,12 +289,12 @@ class PaymentProcessingMessage < SmartMessage::Base
|
|
291
289
|
|
292
290
|
config do
|
293
291
|
transport SmartMessage::Transport.create(:memory, auto_process: true)
|
294
|
-
serializer SmartMessage::Serializer::
|
292
|
+
serializer SmartMessage::Serializer::Json.new
|
295
293
|
end
|
296
294
|
|
297
|
-
def self.process(
|
298
|
-
|
299
|
-
payment =
|
295
|
+
def self.process(decoded_message)
|
296
|
+
# decoded_message is already a message instance
|
297
|
+
payment = decoded_message
|
300
298
|
|
301
299
|
success = process_payment(payment)
|
302
300
|
|
@@ -364,12 +362,12 @@ class LogMessage < SmartMessage::Base
|
|
364
362
|
|
365
363
|
config do
|
366
364
|
transport SmartMessage::Transport.create(:stdout, output: "application.log")
|
367
|
-
serializer SmartMessage::Serializer::
|
365
|
+
serializer SmartMessage::Serializer::Json.new
|
368
366
|
end
|
369
367
|
|
370
|
-
def self.process(
|
371
|
-
|
372
|
-
log_entry =
|
368
|
+
def self.process(decoded_message)
|
369
|
+
# decoded_message is already a message instance
|
370
|
+
log_entry = decoded_message
|
373
371
|
|
374
372
|
formatted_message = format_log_entry(log_entry)
|
375
373
|
|
@@ -414,12 +412,12 @@ class MetricMessage < SmartMessage::Base
|
|
414
412
|
|
415
413
|
config do
|
416
414
|
transport SmartMessage::Transport.create(:memory, auto_process: true)
|
417
|
-
serializer SmartMessage::Serializer::
|
415
|
+
serializer SmartMessage::Serializer::Json.new
|
418
416
|
end
|
419
417
|
|
420
|
-
def self.process(
|
421
|
-
|
422
|
-
metric =
|
418
|
+
def self.process(decoded_message)
|
419
|
+
# decoded_message is already a message instance
|
420
|
+
metric = decoded_message
|
423
421
|
|
424
422
|
# Store metric (would typically go to monitoring system)
|
425
423
|
store_metric(metric)
|
@@ -498,12 +496,12 @@ class MessageGateway < SmartMessage::Base
|
|
498
496
|
# Receive from one transport
|
499
497
|
config do
|
500
498
|
transport SmartMessage::Transport.create(:memory, auto_process: true)
|
501
|
-
serializer SmartMessage::Serializer::
|
499
|
+
serializer SmartMessage::Serializer::Json.new
|
502
500
|
end
|
503
501
|
|
504
|
-
def self.process(
|
505
|
-
|
506
|
-
gateway_message =
|
502
|
+
def self.process(decoded_message)
|
503
|
+
# decoded_message is already a message instance
|
504
|
+
gateway_message = decoded_message
|
507
505
|
|
508
506
|
# Transform and forward to destination system
|
509
507
|
case gateway_message.destination_system
|
@@ -567,8 +565,8 @@ class EmailSystemMessage < SmartMessage::Base
|
|
567
565
|
property :original_payload
|
568
566
|
property :source
|
569
567
|
|
570
|
-
def self.process(
|
571
|
-
puts "📧 Email system processed message from #{
|
568
|
+
def self.process(decoded_message)
|
569
|
+
puts "📧 Email system processed message from #{decoded_message.source}"
|
572
570
|
end
|
573
571
|
end
|
574
572
|
|
@@ -576,8 +574,8 @@ class SMSSystemMessage < SmartMessage::Base
|
|
576
574
|
property :original_payload
|
577
575
|
property :source
|
578
576
|
|
579
|
-
def self.process(
|
580
|
-
puts "📱 SMS system processed message from #{
|
577
|
+
def self.process(decoded_message)
|
578
|
+
puts "📱 SMS system processed message from #{decoded_message.source}"
|
581
579
|
end
|
582
580
|
end
|
583
581
|
|
@@ -587,8 +585,8 @@ class AuditSystemMessage < SmartMessage::Base
|
|
587
585
|
property :source_system
|
588
586
|
property :processed_at
|
589
587
|
|
590
|
-
def self.process(
|
591
|
-
puts "📋 Audit system logged event from #{
|
588
|
+
def self.process(decoded_message)
|
589
|
+
puts "📋 Audit system logged event from #{decoded_message.source_system}"
|
592
590
|
end
|
593
591
|
end
|
594
592
|
|
@@ -623,12 +621,12 @@ class ResilientMessage < SmartMessage::Base
|
|
623
621
|
|
624
622
|
config do
|
625
623
|
transport SmartMessage::Transport.create(:memory, auto_process: true)
|
626
|
-
serializer SmartMessage::Serializer::
|
624
|
+
serializer SmartMessage::Serializer::Json.new
|
627
625
|
end
|
628
626
|
|
629
|
-
def self.process(
|
630
|
-
|
631
|
-
message =
|
627
|
+
def self.process(decoded_message)
|
628
|
+
# decoded_message is already a message instance
|
629
|
+
message = decoded_message
|
632
630
|
|
633
631
|
begin
|
634
632
|
# Simulate potentially failing operation
|
@@ -691,12 +689,12 @@ class DeadLetterMessage < SmartMessage::Base
|
|
691
689
|
|
692
690
|
config do
|
693
691
|
transport SmartMessage::Transport.create(:stdout, output: "dead_letter_queue.log")
|
694
|
-
serializer SmartMessage::Serializer::
|
692
|
+
serializer SmartMessage::Serializer::Json.new
|
695
693
|
end
|
696
694
|
|
697
|
-
def self.process(
|
698
|
-
|
699
|
-
dead_letter =
|
695
|
+
def self.process(decoded_message)
|
696
|
+
# decoded_message is already a message instance
|
697
|
+
dead_letter = decoded_message
|
700
698
|
|
701
699
|
puts "💀 Message sent to dead letter queue:"
|
702
700
|
puts " Original: #{dead_letter.original_message}"
|
@@ -796,9 +794,9 @@ end
|
|
796
794
|
class TestMessage < SmartMessage::Base
|
797
795
|
property :data
|
798
796
|
|
799
|
-
def self.process(
|
800
|
-
|
801
|
-
message =
|
797
|
+
def self.process(decoded_message)
|
798
|
+
# decoded_message is already a message instance
|
799
|
+
message = decoded_message
|
802
800
|
puts "Processed test message: #{message.data}"
|
803
801
|
end
|
804
802
|
end
|
@@ -813,22 +811,46 @@ These examples demonstrate the flexibility and power of SmartMessage for buildin
|
|
813
811
|
|
814
812
|
The `examples/` directory contains complete, runnable programs that demonstrate various SmartMessage features:
|
815
813
|
|
816
|
-
###
|
817
|
-
- **`
|
818
|
-
- **`
|
819
|
-
- **`
|
820
|
-
|
821
|
-
|
822
|
-
- **`
|
823
|
-
- **`
|
824
|
-
- **`
|
825
|
-
- **`
|
826
|
-
- **`
|
827
|
-
- **`
|
828
|
-
- **`
|
829
|
-
|
830
|
-
|
831
|
-
|
814
|
+
### Memory Transport Examples
|
815
|
+
- **`memory/03_point_to_point_orders.rb`** - Point-to-point order processing with payment integration
|
816
|
+
- **`memory/04_publish_subscribe_events.rb`** - Event broadcasting to multiple services (email, SMS, audit)
|
817
|
+
- **`memory/05_many_to_many_chat.rb`** - Interactive chat system with rooms, bots, and human agents
|
818
|
+
- **`memory/07_proc_handlers_demo.rb`** - Flexible message handlers (blocks, procs, lambdas, methods)
|
819
|
+
- **`memory/08_custom_logger_demo.rb`** - Advanced logging with SmartMessage::Logger::Default
|
820
|
+
- **`memory/09_error_handling_demo.rb`** - Comprehensive validation, version mismatch, and error handling
|
821
|
+
- **`memory/10_entity_addressing_basic.rb`** - Basic FROM/TO/REPLY_TO message addressing
|
822
|
+
- **`memory/11_entity_addressing_with_filtering.rb`** - Advanced entity-aware message filtering
|
823
|
+
- **`memory/02_dead_letter_queue_demo.rb`** - Complete Dead Letter Queue system demonstration
|
824
|
+
- **`memory/01_message_deduplication_demo.rb`** - Message deduplication patterns
|
825
|
+
- **`memory/12_regex_filtering_microservices.rb`** - Advanced regex filtering for microservices
|
826
|
+
- **`memory/13_header_block_configuration.rb`** - Header and block configuration examples
|
827
|
+
- **`memory/14_global_configuration_demo.rb`** - Global configuration management
|
828
|
+
- **`memory/15_logger_demo.rb`** - Advanced logging demonstrations
|
829
|
+
|
830
|
+
### Redis Transport Examples
|
831
|
+
- **`redis/01_smart_home_iot_demo.rb`** - Redis-based IoT sensor monitoring with real-time data flow
|
832
|
+
|
833
|
+
### Redis Enhanced Transport Examples
|
834
|
+
- **`redis_enhanced/enhanced_01_basic_patterns.rb`** - Basic enhanced transport patterns
|
835
|
+
- **`redis_enhanced/enhanced_02_fluent_api.rb`** - Fluent API usage examples
|
836
|
+
- **`redis_enhanced/enhanced_03_dual_publishing.rb`** - Dual publishing strategies
|
837
|
+
- **`redis_enhanced/enhanced_04_advanced_routing.rb`** - Advanced message routing
|
838
|
+
|
839
|
+
### Redis Queue Transport Examples
|
840
|
+
- **`redis_queue/01_basic_messaging.rb`** - Basic queue messaging patterns
|
841
|
+
- **`redis_queue/02_pattern_routing.rb`** - Pattern-based message routing
|
842
|
+
- **`redis_queue/03_fluent_api.rb`** - Fluent API for queue operations
|
843
|
+
- **`redis_queue/04_load_balancing.rb`** - Load balancing across workers
|
844
|
+
- **`redis_queue/05_microservices.rb`** - Microservices communication
|
845
|
+
- **`redis_queue/06_emergency_alerts.rb`** - Emergency alert system
|
846
|
+
- **`redis_queue/07_queue_management.rb`** - Queue management utilities
|
847
|
+
- **`redis_queue/01_comprehensive_examples.rb`** - Comprehensive feature demonstration
|
848
|
+
|
849
|
+
### City Scenario (Comprehensive Demo)
|
850
|
+
- **`city_scenario/`** - Complete emergency services simulation with multiple services and AI integration
|
851
|
+
|
852
|
+
### Performance Testing
|
853
|
+
- **`performance_metrics/`** - Benchmarking tools and performance comparisons
|
832
854
|
|
833
855
|
### Running Examples
|
834
856
|
|
@@ -836,12 +858,14 @@ The `examples/` directory contains complete, runnable programs that demonstrate
|
|
836
858
|
# Navigate to the SmartMessage directory
|
837
859
|
cd smart_message
|
838
860
|
|
839
|
-
# Run
|
840
|
-
ruby examples/
|
841
|
-
ruby examples/
|
861
|
+
# Run examples from their respective transport directories
|
862
|
+
ruby examples/memory/03_point_to_point_orders.rb
|
863
|
+
ruby examples/memory/02_dead_letter_queue_demo.rb
|
864
|
+
ruby examples/redis/01_smart_home_iot_demo.rb
|
865
|
+
ruby examples/redis_queue/01_basic_messaging.rb
|
842
866
|
|
843
|
-
# For
|
844
|
-
cd examples/
|
867
|
+
# For city scenario comprehensive demo
|
868
|
+
cd examples/city_scenario && ./start_demo.sh
|
845
869
|
```
|
846
870
|
|
847
871
|
Each example is self-contained and includes:
|
@@ -853,16 +877,18 @@ Each example is self-contained and includes:
|
|
853
877
|
|
854
878
|
### Example Features Demonstrated
|
855
879
|
|
856
|
-
| Example |
|
857
|
-
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
880
|
+
| Example | Transport | Features | Use Case |
|
881
|
+
|---------|-----------|----------|----------|
|
882
|
+
| memory/03 | Memory/STDOUT | Point-to-point, validation | Order processing |
|
883
|
+
| memory/04 | Memory/STDOUT | Pub-sub, multiple handlers | Event broadcasting |
|
884
|
+
| memory/05 | Memory | Many-to-many, bots | Chat systems |
|
885
|
+
| redis/01 | Redis | IoT, real-time, addressing | Smart home monitoring |
|
886
|
+
| memory/07 | Memory | Proc handlers, flexibility | Dynamic message handling |
|
887
|
+
| memory/08 | Memory/STDOUT | Custom logging, lifecycle | Production logging |
|
888
|
+
| memory/09 | Memory/STDOUT | Error handling, validation | Robust message systems |
|
889
|
+
| memory/10-11 | Memory/STDOUT | Entity addressing, filtering | Microservice communication |
|
890
|
+
| memory/02 | Memory | DLQ, circuit breakers, replay | Production reliability |
|
891
|
+
| redis_queue/* | Redis Queue | Load balancing, persistence | Production messaging |
|
892
|
+
| city_scenario/* | Redis | AI integration, health monitoring | Emergency services |
|
867
893
|
|
868
894
|
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,13 @@ 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::
|
95
|
+
serializer SmartMessage::Serializer::Json.new
|
64
96
|
end
|
65
97
|
|
66
98
|
# Define how to process received messages
|
67
|
-
def self.process(
|
68
|
-
#
|
69
|
-
|
70
|
-
welcome = new(data)
|
99
|
+
def self.process(decoded_message)
|
100
|
+
# decoded_message is already a message instance
|
101
|
+
welcome = decoded_message
|
71
102
|
|
72
103
|
# Process the welcome message
|
73
104
|
puts "🎉 Welcome #{welcome.user_name}!"
|
@@ -186,7 +217,7 @@ Serializers handle message encoding/decoding:
|
|
186
217
|
|
187
218
|
```ruby
|
188
219
|
# JSON serialization (built-in)
|
189
|
-
serializer SmartMessage::Serializer::
|
220
|
+
serializer SmartMessage::Serializer::Json.new
|
190
221
|
```
|
191
222
|
|
192
223
|
### Message Handlers
|
@@ -265,16 +296,15 @@ payment.to('backup-gateway') # Override destination
|
|
265
296
|
payment.publish
|
266
297
|
```
|
267
298
|
|
268
|
-
For more details, see [Entity Addressing](addressing.md).
|
299
|
+
For more details, see [Entity Addressing](../core-concepts/addressing.md).
|
269
300
|
|
270
301
|
## Next Steps
|
271
302
|
|
272
303
|
Now that you have the basics working, explore:
|
273
304
|
|
274
|
-
- [Architecture Overview](architecture.md) - Understand how SmartMessage works
|
305
|
+
- [Architecture Overview](../core-concepts/architecture.md) - Understand how SmartMessage works
|
275
306
|
- [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
|
307
|
+
- [Transports](../reference/transports.md) - Learn about different transport options
|
278
308
|
|
279
309
|
## Common Patterns
|
280
310
|
|
@@ -291,12 +321,12 @@ class NotificationMessage < SmartMessage::Base
|
|
291
321
|
|
292
322
|
config do
|
293
323
|
transport SmartMessage::Transport.create(:memory, auto_process: true)
|
294
|
-
serializer SmartMessage::Serializer::
|
324
|
+
serializer SmartMessage::Serializer::Json.new
|
295
325
|
end
|
296
326
|
|
297
|
-
def self.process(
|
298
|
-
|
299
|
-
notification =
|
327
|
+
def self.process(decoded_message)
|
328
|
+
# decoded_message is already a message instance
|
329
|
+
notification = decoded_message
|
300
330
|
|
301
331
|
# Send email, SMS, push notification, etc.
|
302
332
|
send_notification(notification)
|
@@ -334,7 +364,7 @@ class EventMessage < SmartMessage::Base
|
|
334
364
|
|
335
365
|
config do
|
336
366
|
transport SmartMessage::Transport.create(:stdout, output: 'events.log')
|
337
|
-
serializer SmartMessage::Serializer::
|
367
|
+
serializer SmartMessage::Serializer::Json.new
|
338
368
|
end
|
339
369
|
end
|
340
370
|
|
@@ -348,6 +378,5 @@ EventMessage.new(
|
|
348
378
|
|
349
379
|
## Need Help?
|
350
380
|
|
351
|
-
- Check the [Troubleshooting Guide](troubleshooting.md)
|
352
|
-
- Review the [API Reference](api-reference.md)
|
381
|
+
- Check the [Troubleshooting Guide](../development/troubleshooting.md)
|
353
382
|
- Look at more [Examples](examples.md)
|