smart_message 0.0.12 → 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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -1
  3. data/Gemfile.lock +5 -5
  4. data/docs/core-concepts/architecture.md +5 -10
  5. data/docs/getting-started/examples.md +0 -12
  6. data/docs/getting-started/quick-start.md +4 -9
  7. data/docs/index.md +4 -4
  8. data/docs/reference/serializers.md +160 -488
  9. data/docs/reference/transports.md +1 -125
  10. data/docs/transports/redis-transport-comparison.md +215 -350
  11. data/docs/transports/redis-transport.md +3 -22
  12. data/examples/README.md +6 -9
  13. data/examples/city_scenario/README.md +1 -1
  14. data/examples/city_scenario/messages/emergency_911_message.rb +0 -1
  15. data/examples/city_scenario/messages/emergency_resolved_message.rb +0 -1
  16. data/examples/city_scenario/messages/fire_dispatch_message.rb +0 -1
  17. data/examples/city_scenario/messages/fire_emergency_message.rb +0 -1
  18. data/examples/city_scenario/messages/health_check_message.rb +0 -1
  19. data/examples/city_scenario/messages/health_status_message.rb +0 -1
  20. data/examples/city_scenario/messages/police_dispatch_message.rb +0 -1
  21. data/examples/city_scenario/messages/silent_alarm_message.rb +0 -1
  22. data/examples/memory/01_message_deduplication_demo.rb +0 -2
  23. data/examples/memory/02_dead_letter_queue_demo.rb +0 -3
  24. data/examples/memory/03_point_to_point_orders.rb +0 -2
  25. data/examples/memory/04_publish_subscribe_events.rb +0 -1
  26. data/examples/memory/05_many_to_many_chat.rb +0 -3
  27. data/examples/memory/07_proc_handlers_demo.rb +0 -1
  28. data/examples/memory/08_custom_logger_demo.rb +0 -4
  29. data/examples/memory/09_error_handling_demo.rb +0 -3
  30. data/examples/memory/10_entity_addressing_basic.rb +0 -6
  31. data/examples/memory/11_entity_addressing_with_filtering.rb +0 -4
  32. data/examples/memory/12_regex_filtering_microservices.rb +0 -1
  33. data/examples/memory/13_header_block_configuration.rb +0 -5
  34. data/examples/memory/14_global_configuration_demo.rb +0 -2
  35. data/examples/memory/15_logger_demo.rb +0 -1
  36. data/examples/memory/README.md +3 -3
  37. data/examples/redis/01_smart_home_iot_demo.rb +0 -4
  38. data/examples/redis/README.md +0 -2
  39. data/lib/smart_message/base.rb +19 -10
  40. data/lib/smart_message/configuration.rb +2 -23
  41. data/lib/smart_message/dead_letter_queue.rb +1 -1
  42. data/lib/smart_message/messaging.rb +3 -62
  43. data/lib/smart_message/plugins.rb +1 -42
  44. data/lib/smart_message/transport/base.rb +42 -8
  45. data/lib/smart_message/transport/memory_transport.rb +23 -4
  46. data/lib/smart_message/transport/redis_transport.rb +11 -0
  47. data/lib/smart_message/transport/registry.rb +0 -1
  48. data/lib/smart_message/transport/stdout_transport.rb +28 -10
  49. data/lib/smart_message/transport.rb +0 -1
  50. data/lib/smart_message/version.rb +1 -1
  51. metadata +2 -28
  52. data/docs/guides/redis-queue-getting-started.md +0 -697
  53. data/docs/guides/redis-queue-patterns.md +0 -889
  54. data/docs/guides/redis-queue-production.md +0 -1091
  55. data/docs/transports/redis-enhanced-transport.md +0 -524
  56. data/docs/transports/redis-queue-transport.md +0 -1304
  57. data/examples/redis_enhanced/README.md +0 -319
  58. data/examples/redis_enhanced/enhanced_01_basic_patterns.rb +0 -233
  59. data/examples/redis_enhanced/enhanced_02_fluent_api.rb +0 -331
  60. data/examples/redis_enhanced/enhanced_03_dual_publishing.rb +0 -281
  61. data/examples/redis_enhanced/enhanced_04_advanced_routing.rb +0 -419
  62. data/examples/redis_queue/01_basic_messaging.rb +0 -221
  63. data/examples/redis_queue/01_comprehensive_examples.rb +0 -508
  64. data/examples/redis_queue/02_pattern_routing.rb +0 -405
  65. data/examples/redis_queue/03_fluent_api.rb +0 -422
  66. data/examples/redis_queue/04_load_balancing.rb +0 -486
  67. data/examples/redis_queue/05_microservices.rb +0 -735
  68. data/examples/redis_queue/06_emergency_alerts.rb +0 -777
  69. data/examples/redis_queue/07_queue_management.rb +0 -587
  70. data/examples/redis_queue/README.md +0 -366
  71. data/examples/redis_queue/enhanced_01_basic_patterns.rb +0 -233
  72. data/examples/redis_queue/enhanced_02_fluent_api.rb +0 -331
  73. data/examples/redis_queue/enhanced_03_dual_publishing.rb +0 -281
  74. data/examples/redis_queue/enhanced_04_advanced_routing.rb +0 -419
  75. data/examples/redis_queue/redis_queue_architecture.svg +0 -148
  76. data/lib/smart_message/transport/redis_enhanced_transport.rb +0 -399
  77. data/lib/smart_message/transport/redis_queue_transport.rb +0 -555
@@ -430,24 +430,6 @@ All subscribers receive all messages:
430
430
  # No load balancing between subscribers
431
431
  ```
432
432
 
433
- ## Migration to Enhanced Transport
434
-
435
- When you need advanced routing, consider upgrading to Enhanced Transport:
436
-
437
- ```ruby
438
- # From Redis Transport
439
- SmartMessage.configure do |config|
440
- config.default_transport = SmartMessage::Transport::RedisTransport.new
441
- end
442
-
443
- # To Enhanced Transport (with backward compatibility)
444
- SmartMessage.configure do |config|
445
- config.default_transport = SmartMessage::Transport::RedisEnhancedTransport.new
446
- end
447
-
448
- # All existing messages continue to work
449
- # New messages gain pattern-matching capabilities
450
- ```
451
433
 
452
434
  ## Examples
453
435
 
@@ -503,7 +485,6 @@ For more Redis Transport examples and patterns, also see:
503
485
 
504
486
  ## Related Documentation
505
487
 
506
- - [Redis Enhanced Transport](redis-enhanced-transport.md) - Advanced routing with patterns
507
- - [Redis Queue Transport](redis-queue-transport.md) - Persistent queues with load balancing
508
- - [Transport Comparison](redis-transport-comparison.md) - Compare all Redis transports
509
- - [Transport Overview](../reference/transports.md) - All available transports
488
+ - [Transport Overview](../reference/transports.md) - All available transports
489
+ - [Examples & Use Cases](../getting-started/examples.md) - Practical usage patterns
490
+ - [Architecture Overview](../core-concepts/architecture.md) - How SmartMessage works
data/examples/README.md CHANGED
@@ -40,7 +40,7 @@ cd city_scenario
40
40
  **Key Features:**
41
41
  - Request-response messaging pattern
42
42
  - Error handling and payment validation
43
- - JSON serialization of complex business objects
43
+ - Automatic serialization of complex business objects by transport
44
44
  - Service-to-service communication
45
45
 
46
46
  **Messages Used:**
@@ -393,7 +393,6 @@ Most examples use `StdoutTransport` with loopback enabled for demonstration purp
393
393
  ```ruby
394
394
  config do
395
395
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
396
- serializer SmartMessage::Serializer::JSON.new
397
396
  end
398
397
  ```
399
398
 
@@ -406,13 +405,12 @@ config do
406
405
  db: 1,
407
406
  auto_subscribe: true
408
407
  )
409
- serializer SmartMessage::Serializer::JSON.new
410
408
  end
411
409
  ```
412
410
 
413
411
  **For Production Use:**
414
412
  - Use production transports like Redis (see example #4), RabbitMQ, or Kafka
415
- - Configure appropriate serializers for your data needs
413
+ - Transports handle serialization automatically
416
414
  - Add proper error handling and logging
417
415
  - Implement monitoring and metrics
418
416
 
@@ -547,7 +545,6 @@ class MyCustomMessage < SmartMessage::Base
547
545
 
548
546
  config do
549
547
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
550
- serializer SmartMessage::Serializer::JSON.new
551
548
  end
552
549
  end
553
550
  ```
@@ -676,9 +673,9 @@ When adapting these examples for production:
676
673
  - Implement proper error handling
677
674
 
678
675
  2. **Serialization:**
679
- - Choose appropriate serializers for your data
680
- - Consider performance and compatibility requirements
681
- - Handle schema evolution
676
+ - Transports handle serialization automatically
677
+ - Choose transports based on serialization requirements
678
+ - Handle schema evolution at the message level
682
679
 
683
680
  3. **Monitoring:**
684
681
  - Add logging and metrics
@@ -699,7 +696,7 @@ When adapting these examples for production:
699
696
 
700
697
  - [SmartMessage Documentation](../docs/README.md)
701
698
  - [Transport Layer Guide](../docs/transports.md)
702
- - [Serialization Guide](../docs/serializers.md)
699
+ - [Serialization Guide](../docs/serializers.md) (Note: Serialization is now handled by transports)
703
700
  - [Architecture Overview](../docs/architecture.md)
704
701
 
705
702
  ## Questions and Contributions
@@ -372,7 +372,7 @@ All messages include comprehensive headers:
372
372
  "publisher_pid": 12345,
373
373
  "version": 1,
374
374
  "from": "house-sensor-01",
375
- "serializer": "SmartMessage::Serializer::Json"
375
+ "transport": "SmartMessage::Transport::RedisTransport"
376
376
  },
377
377
  "_sm_payload": {
378
378
  "location": "123 Oak Street",
@@ -10,7 +10,6 @@ module Messages
10
10
  description 'Emergency 911 call for reporting fires, crimes, accidents, medical emergencies, or other urgent situations requiring police, fire, or medical response'
11
11
 
12
12
  transport SmartMessage::Transport::RedisTransport.new
13
- serializer SmartMessage::Serializer::Json.new
14
13
 
15
14
  VALID_EMERGENCY_TYPES = %w[fire medical crime accident hazmat rescue other]
16
15
  VALID_SEVERITY = %w[critical high medium low]
@@ -14,7 +14,6 @@ module Messages
14
14
  description 'Emergency incident closure notification message broadcast by emergency services when incidents are successfully resolved, providing completion status, response duration, outcome details, and unit deployment information to all city services for operational awareness and incident tracking'
15
15
 
16
16
  transport SmartMessage::Transport::RedisTransport.new
17
- serializer SmartMessage::Serializer::Json.new
18
17
 
19
18
  property :incident_id, required: true,
20
19
  description: 'Unique identifier of the emergency incident that was resolved'
@@ -13,7 +13,6 @@ module Messages
13
13
  description 'Emergency fire suppression dispatch coordination message sent by the Fire Department in response to fire emergencies, containing fire engine assignments, specialized equipment deployment, and tactical response information for various fire types, rescue operations, and hazardous material incidents'
14
14
 
15
15
  transport SmartMessage::Transport::RedisTransport.new
16
- serializer SmartMessage::Serializer::Json.new
17
16
 
18
17
  property :dispatch_id, required: true,
19
18
  description: 'Unique hexadecimal identifier for this fire department dispatch operation'
@@ -13,7 +13,6 @@ module Messages
13
13
  description "Critical fire emergency alert message sent by residential monitoring systems to the Fire Department when smoke, heat, or fire is detected, triggering immediate emergency response with fire engine dispatch, specialized equipment deployment, and rescue operations based on fire type, severity, and occupant safety status"
14
14
 
15
15
  transport SmartMessage::Transport::RedisTransport.new
16
- serializer SmartMessage::Serializer::Json.new
17
16
 
18
17
  VALID_FIRE_TYPES = %w[fire kitchen electrical basement garage wildfire]
19
18
  VALID_SEVERITY = %w[small medium large out_of_control]
@@ -14,7 +14,6 @@ module Messages
14
14
  description "Health monitoring message broadcast by the Health Department every 5 seconds to verify operational status of all city services including police, fire, banks, and residential monitoring systems"
15
15
 
16
16
  transport SmartMessage::Transport::RedisTransport.new
17
- serializer SmartMessage::Serializer::Json.new
18
17
 
19
18
  property :check_id, required: true,
20
19
  description: "Unique identifier for this health check request (UUID format)"
@@ -16,7 +16,6 @@ module Messages
16
16
  VALID_STATUS = %w[healthy warning critical failed]
17
17
 
18
18
  transport SmartMessage::Transport::RedisTransport.new
19
- serializer SmartMessage::Serializer::Json.new
20
19
 
21
20
  property :service_name, required: true,
22
21
  description: "Name of the city service reporting its status (e.g., 'police-department', 'fire-department')"
@@ -16,7 +16,6 @@ module Messages
16
16
  DESC
17
17
 
18
18
  transport SmartMessage::Transport::RedisTransport.new
19
- serializer SmartMessage::Serializer::Json.new
20
19
 
21
20
  VALID_PRIORITY = %w[low medium high emergency]
22
21
 
@@ -17,7 +17,6 @@ module Messages
17
17
  DESC
18
18
 
19
19
  transport SmartMessage::Transport::RedisTransport.new
20
- serializer SmartMessage::Serializer::Json.new
21
20
 
22
21
  VALID_ALARM_TYPES = %w[robbery vault_breach suspicious_activity]
23
22
  VALID_SEVERITY = %w[low medium high critical]
@@ -64,11 +64,9 @@ def demonstrate_deduplication
64
64
  transport = SmartMessage::Transport::MemoryTransport.new
65
65
 
66
66
  OrderMessage.transport(transport)
67
- OrderMessage.serializer(SmartMessage::Serializer::Json.new)
68
67
  OrderMessage.subscribe('OrderMessage.process')
69
68
 
70
69
  NotificationMessage.transport(transport)
71
- NotificationMessage.serializer(SmartMessage::Serializer::Json.new)
72
70
  NotificationMessage.subscribe('NotificationMessage.process')
73
71
 
74
72
  # Clear any previous state
@@ -45,7 +45,6 @@ class PaymentMessage < SmartMessage::Base
45
45
 
46
46
  config do
47
47
  transport SmartMessage::Transport.create(:memory)
48
- serializer SmartMessage::Serializer::Json.new
49
48
  end
50
49
 
51
50
  def self.process(wrapper)
@@ -68,7 +67,6 @@ class OrderMessage < SmartMessage::Base
68
67
 
69
68
  config do
70
69
  transport SmartMessage::Transport.create(:memory)
71
- serializer SmartMessage::Serializer::Json.new
72
70
  end
73
71
 
74
72
  def self.process(wrapper)
@@ -90,7 +88,6 @@ class NotificationMessage < SmartMessage::Base
90
88
 
91
89
  config do
92
90
  transport SmartMessage::Transport.create(:memory)
93
- serializer SmartMessage::Serializer::Json.new
94
91
  end
95
92
 
96
93
  def self.process(wrapper)
@@ -36,7 +36,6 @@ class OrderMessage < SmartMessage::Base
36
36
  # Configure to use memory transport for this example
37
37
  config do
38
38
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
39
- serializer SmartMessage::Serializer::Json.new
40
39
  end
41
40
 
42
41
  # Default processing - just logs the order
@@ -62,7 +61,6 @@ class PaymentResponseMessage < SmartMessage::Base
62
61
 
63
62
  config do
64
63
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
65
- serializer SmartMessage::Serializer::Json.new
66
64
  end
67
65
 
68
66
  def self.process(message)
@@ -32,7 +32,6 @@ class UserEventMessage < SmartMessage::Base
32
32
 
33
33
  config do
34
34
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
35
- serializer SmartMessage::Serializer::Json.new
36
35
  end
37
36
 
38
37
  # Default processor - just logs the event
@@ -37,7 +37,6 @@ class ChatMessage < SmartMessage::Base
37
37
 
38
38
  config do
39
39
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
40
- serializer SmartMessage::Serializer::Json.new
41
40
  end
42
41
 
43
42
  def self.process(wrapper)
@@ -66,7 +65,6 @@ class BotCommandMessage < SmartMessage::Base
66
65
 
67
66
  config do
68
67
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
69
- serializer SmartMessage::Serializer::Json.new
70
68
  end
71
69
 
72
70
  def self.process(wrapper)
@@ -95,7 +93,6 @@ class SystemNotificationMessage < SmartMessage::Base
95
93
 
96
94
  config do
97
95
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
98
- serializer SmartMessage::Serializer::Json.new
99
96
  end
100
97
 
101
98
  def self.process(wrapper)
@@ -29,7 +29,6 @@ class NotificationMessage < SmartMessage::Base
29
29
 
30
30
  config do
31
31
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
32
- serializer SmartMessage::Serializer::Json.new
33
32
  end
34
33
 
35
34
  # Default handler
@@ -293,7 +293,6 @@ class OrderProcessingMessage < SmartMessage::Base
293
293
 
294
294
  config do
295
295
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
296
- serializer SmartMessage::Serializer::Json.new
297
296
 
298
297
  # Configure multi-logger to demonstrate different logging approaches
299
298
  logger SmartMessage::Logger::MultiLogger.new(
@@ -364,7 +363,6 @@ class NotificationMessage < SmartMessage::Base
364
363
 
365
364
  config do
366
365
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
367
- serializer SmartMessage::Serializer::Json.new
368
366
 
369
367
  # Use only file logger for notifications
370
368
  logger SmartMessage::Logger::FileLogger.new('logs/notifications.log', level: Logger::WARN)
@@ -401,7 +399,6 @@ class StandardLoggerMessage < SmartMessage::Base
401
399
 
402
400
  config do
403
401
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
404
- serializer SmartMessage::Serializer::Json.new
405
402
 
406
403
  # Example 1: Using Ruby's standard Logger directly
407
404
  # Create a standard Ruby logger that logs to STDOUT
@@ -439,7 +436,6 @@ class DefaultLoggerMessage < SmartMessage::Base
439
436
 
440
437
  config do
441
438
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
442
- serializer SmartMessage::Serializer::Json.new
443
439
 
444
440
  # Use the built-in default logger - simplest option!
445
441
  logger SmartMessage::Logger::Default.new
@@ -50,7 +50,6 @@ class UserRegistrationMessage < SmartMessage::Base
50
50
 
51
51
  config do
52
52
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
53
- serializer SmartMessage::Serializer::Json.new
54
53
  end
55
54
 
56
55
  def self.process(wrapper)
@@ -99,7 +98,6 @@ class UserRegistrationMessageV2 < SmartMessage::Base
99
98
 
100
99
  config do
101
100
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
102
- serializer SmartMessage::Serializer::Json.new
103
101
  end
104
102
 
105
103
  def self.process(wrapper)
@@ -121,7 +119,6 @@ class MultiRequiredMessage < SmartMessage::Base
121
119
 
122
120
  config do
123
121
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
124
- serializer SmartMessage::Serializer::Json.new
125
122
  end
126
123
  end
127
124
 
@@ -40,7 +40,6 @@ class OrderMessage < SmartMessage::Base
40
40
 
41
41
  config do
42
42
  transport SmartMessage::Transport.create(:stdout, loopback: true)
43
- serializer SmartMessage::Serializer::Json.new
44
43
  end
45
44
 
46
45
  def self.process(wrapper)
@@ -93,7 +92,6 @@ class SystemAnnouncementMessage < SmartMessage::Base
93
92
 
94
93
  config do
95
94
  transport SmartMessage::Transport.create(:stdout, loopback: true)
96
- serializer SmartMessage::Serializer::Json.new
97
95
  end
98
96
 
99
97
  def self.process(wrapper)
@@ -145,7 +143,6 @@ class UserLookupRequest < SmartMessage::Base
145
143
 
146
144
  config do
147
145
  transport SmartMessage::Transport.create(:stdout, loopback: true)
148
- serializer SmartMessage::Serializer::Json.new
149
146
  end
150
147
 
151
148
  def self.process(wrapper)
@@ -179,7 +176,6 @@ class UserLookupResponse < SmartMessage::Base
179
176
 
180
177
  config do
181
178
  transport SmartMessage::Transport.create(:stdout, loopback: true)
182
- serializer SmartMessage::Serializer::Json.new
183
179
  end
184
180
 
185
181
  def self.process(wrapper)
@@ -251,7 +247,6 @@ class PaymentMessage < SmartMessage::Base
251
247
 
252
248
  config do
253
249
  transport SmartMessage::Transport.create(:stdout, loopback: true)
254
- serializer SmartMessage::Serializer::Json.new
255
250
  end
256
251
 
257
252
  def self.process(wrapper)
@@ -326,7 +321,6 @@ class ExternalAPIMessage < SmartMessage::Base
326
321
 
327
322
  config do
328
323
  transport SmartMessage::Transport.create(:stdout, loopback: true)
329
- serializer SmartMessage::Serializer::Json.new
330
324
  end
331
325
 
332
326
  def self.process(wrapper)
@@ -37,7 +37,6 @@ class ServiceMessage < SmartMessage::Base
37
37
 
38
38
  config do
39
39
  transport SmartMessage::Transport.create(:stdout, loopback: true)
40
- serializer SmartMessage::Serializer::Json.new
41
40
  end
42
41
 
43
42
  # Different handlers for different subscription filters
@@ -154,7 +153,6 @@ class AlertMessage < SmartMessage::Base
154
153
 
155
154
  config do
156
155
  transport SmartMessage::Transport.create(:stdout, loopback: true)
157
- serializer SmartMessage::Serializer::Json.new
158
156
  end
159
157
 
160
158
  def self.process_critical_or_broadcast(wrapper)
@@ -262,7 +260,6 @@ class OrderMessage < SmartMessage::Base
262
260
 
263
261
  config do
264
262
  transport SmartMessage::Transport.create(:stdout, loopback: true)
265
- serializer SmartMessage::Serializer::Json.new
266
263
  end
267
264
 
268
265
  def self.process_high_priority(wrapper)
@@ -357,7 +354,6 @@ class ServiceRequest < SmartMessage::Base
357
354
 
358
355
  config do
359
356
  transport SmartMessage::Transport.create(:stdout, loopback: true)
360
- serializer SmartMessage::Serializer::Json.new
361
357
  end
362
358
 
363
359
  def self.process_api_requests(wrapper)
@@ -31,7 +31,6 @@ class MicroserviceMessage < SmartMessage::Base
31
31
  # Configure with STDOUT transport for demo visibility
32
32
  config do
33
33
  transport SmartMessage::Transport::StdoutTransport.new(loopback: true)
34
- serializer SmartMessage::Serializer::Json.new
35
34
  end
36
35
  end
37
36
 
@@ -32,7 +32,6 @@ class DirectMethodMessage < SmartMessage::Base
32
32
 
33
33
  config do
34
34
  transport SmartMessage::Transport.create(:stdout)
35
- serializer SmartMessage::Serializer::Json.new
36
35
  end
37
36
  end
38
37
 
@@ -63,7 +62,6 @@ class HeaderBlockMessage < SmartMessage::Base
63
62
 
64
63
  config do
65
64
  transport SmartMessage::Transport.create(:stdout)
66
- serializer SmartMessage::Serializer::Json.new
67
65
  end
68
66
  end
69
67
 
@@ -96,7 +94,6 @@ class MixedConfigMessage < SmartMessage::Base
96
94
 
97
95
  config do
98
96
  transport SmartMessage::Transport.create(:stdout)
99
- serializer SmartMessage::Serializer::Json.new
100
97
  end
101
98
  end
102
99
 
@@ -127,7 +124,6 @@ class FlexibleMessage < SmartMessage::Base
127
124
 
128
125
  config do
129
126
  transport SmartMessage::Transport.create(:stdout)
130
- serializer SmartMessage::Serializer::Json.new
131
127
  end
132
128
  end
133
129
 
@@ -234,7 +230,6 @@ class CheckableMessage < SmartMessage::Base
234
230
 
235
231
  config do
236
232
  transport SmartMessage::Transport.create(:stdout)
237
- serializer SmartMessage::Serializer::Json.new
238
233
  end
239
234
  end
240
235
 
@@ -62,7 +62,6 @@ class NotificationMessage < SmartMessage::Base
62
62
  # Explicitly use global configuration for demonstration
63
63
  config do
64
64
  transport SmartMessage::Transport.default
65
- serializer SmartMessage::Serializer.default
66
65
  logger SmartMessage::Logger.default
67
66
  end
68
67
 
@@ -88,7 +87,6 @@ class OrderStatusMessage < SmartMessage::Base
88
87
  # Explicitly use global configuration for demonstration
89
88
  config do
90
89
  transport SmartMessage::Transport.default
91
- serializer SmartMessage::Serializer.default
92
90
  logger SmartMessage::Logger.default
93
91
  end
94
92
 
@@ -273,7 +273,6 @@ class DemoMessage < SmartMessage::Base
273
273
 
274
274
  config do
275
275
  transport SmartMessage::Transport::StdoutTransport.new
276
- serializer SmartMessage::Serializer::Json.new
277
276
  from 'demo-logger-app'
278
277
  end
279
278
 
@@ -35,7 +35,7 @@ These transports keep all message routing in-memory within the current Ruby proc
35
35
  **Transport:** StdoutTransport with loopback
36
36
  - Order processing system between OrderService and PaymentService
37
37
  - Request/response message pattern
38
- - JSON serialization of complex order data
38
+ - Automatic serialization of complex order data by transport
39
39
  - Bidirectional communication flow
40
40
 
41
41
  ### 📢 04_publish_subscribe_events.rb
@@ -121,8 +121,8 @@ These transports keep all message routing in-memory within the current Ruby proc
121
121
  ### 🌍 14_global_configuration_demo.rb
122
122
  **Demonstrates:** Global SmartMessage configuration
123
123
  **Transport:** StdoutTransport with loopback
124
- - Global transport and serializer settings
125
- - Configuration inheritance
124
+ - Global transport settings
125
+ - Configuration inheritance (serialization handled by transport)
126
126
  - Default settings management
127
127
  - Application-wide configuration patterns
128
128
 
@@ -79,7 +79,6 @@ class SensorDataMessage < SmartMessage::Base
79
79
 
80
80
  config do
81
81
  transport SHARED_TRANSPORT
82
- serializer SmartMessage::Serializer::Json.new
83
82
  end
84
83
 
85
84
  def self.process(wrapper)
@@ -114,7 +113,6 @@ class DeviceCommandMessage < SmartMessage::Base
114
113
 
115
114
  config do
116
115
  transport SHARED_TRANSPORT
117
- serializer SmartMessage::Serializer::Json.new
118
116
  end
119
117
 
120
118
  def self.process(wrapper)
@@ -147,7 +145,6 @@ class AlertMessage < SmartMessage::Base
147
145
 
148
146
  config do
149
147
  transport SHARED_TRANSPORT
150
- serializer SmartMessage::Serializer::Json.new
151
148
  end
152
149
 
153
150
  def self.process(wrapper)
@@ -176,7 +173,6 @@ class DashboardStatusMessage < SmartMessage::Base
176
173
 
177
174
  config do
178
175
  transport SHARED_TRANSPORT
179
- serializer SmartMessage::Serializer::Json.new
180
176
  end
181
177
 
182
178
  def self.process(wrapper)
@@ -135,7 +135,6 @@ SmartMessage.configure do |config|
135
135
  url: 'redis://localhost:6379',
136
136
  db: 1 # Optional: use specific Redis database
137
137
  )
138
- config.serializer = SmartMessage::Serializer::Json.new
139
138
  end
140
139
  ```
141
140
 
@@ -147,7 +146,6 @@ class MyMessage < SmartMessage::Base
147
146
  url: 'redis://localhost:6379',
148
147
  db: 2
149
148
  )
150
- serializer SmartMessage::Serializer::Json.new
151
149
  end
152
150
  end
153
151
  ```
@@ -50,7 +50,6 @@ module SmartMessage
50
50
  # instance-level override of class plugins
51
51
  # Don't use fallback defaults here - let the methods handle fallbacks when actually used
52
52
  @transport = (self.class.class_variable_get(:@@transport) rescue nil)
53
- @serializer = (self.class.class_variable_get(:@@serializer) rescue nil)
54
53
 
55
54
  # Check if we're reconstructing from serialized data (complete header provided)
56
55
  if props[:_sm_header]
@@ -71,8 +70,8 @@ module SmartMessage
71
70
  @to = header.to
72
71
  @reply_to = header.reply_to
73
72
 
74
- # Extract payload properties
75
- payload_props = props[:_sm_payload] || {}
73
+ # Extract payload properties directly from props (flat structure)
74
+ payload_props = props.except(:_sm_header)
76
75
 
77
76
  attributes = {
78
77
  _sm_header: header
@@ -132,7 +131,7 @@ module SmartMessage
132
131
  # Extract payload properties (non-header properties)
133
132
  payload_props = self.class.properties.each_with_object({}) do |prop, hash|
134
133
  next if prop == :_sm_header
135
- hash[prop.to_s] = self[prop] # Use string keys to match old format
134
+ hash[prop.to_s] = self[prop] # Access property value
136
135
  end
137
136
 
138
137
  JSON.generate(payload_props)
@@ -154,29 +153,39 @@ module SmartMessage
154
153
 
155
154
 
156
155
 
156
+ # Convert message to hash for serialization
157
+ def to_hash
158
+ # Get all properties and their values
159
+ hash = {}
160
+ self.class.properties.each do |prop|
161
+ hash[prop] = self[prop]
162
+ end
163
+ hash
164
+ end
165
+
157
166
  ###########################################################
158
167
  ## class methods
159
168
 
160
169
  class << self
161
170
  # Decode a complete serialized message back to a message instance
171
+ # Note: This method is no longer used with transport-based serialization
172
+ # Transports handle decoding and create message instances directly
162
173
  # @param serialized_message [String] The serialized message content
163
174
  # @return [SmartMessage::Base] The decoded message instance
164
175
  def decode(serialized_message)
165
176
  begin
166
177
  (self.logger || SmartMessage::Logger.default).info { "[SmartMessage] Received: #{self.name} (#{serialized_message.bytesize} bytes)" }
167
178
 
168
- # Use the class's configured serializer to decode the message
169
- serializer = self.serializer || SmartMessage::Serializer.default
170
-
171
- # Deserialize the complete message
172
- deserialized_data = serializer.decode(serialized_message)
179
+ # This method is deprecated - transports now handle serialization
180
+ # For backward compatibility, try to decode as JSON
181
+ require 'json'
182
+ deserialized_data = JSON.parse(serialized_message)
173
183
 
174
184
  # Create new message instance with the complete deserialized data
175
185
  if deserialized_data.is_a?(Hash)
176
186
  # Convert string keys to symbols for compatibility with keyword arguments
177
187
  symbol_props = deserialized_data.transform_keys(&:to_sym)
178
188
 
179
- # With single-tier serialization, use the complete deserialized message structure
180
189
  message = self.new(**symbol_props)
181
190
 
182
191
  (self.logger || SmartMessage::Logger.default).debug { "[SmartMessage] Deserialized message: #{self.name}" }