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.
- checksums.yaml +4 -4
- data/.github/workflows/deploy-github-pages.yml +38 -0
- data/.gitignore +5 -0
- data/CHANGELOG.md +64 -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} +80 -145
- 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} +103 -89
- data/docs/{getting-started.md → getting-started/quick-start.md} +47 -23
- 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/reference/serializers.md +245 -0
- data/docs/{transports.md → reference/transports.md} +9 -11
- data/docs/transports/memory-transport.md +374 -0
- data/docs/transports/redis-transport-comparison.md +361 -0
- data/docs/transports/redis-transport.md +490 -0
- data/examples/README.md +104 -14
- 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 +80 -0
- data/examples/city_scenario/messages/emergency_resolved_message.rb +42 -0
- data/examples/city_scenario/messages/fire_dispatch_message.rb +42 -0
- data/examples/city_scenario/messages/fire_emergency_message.rb +44 -0
- data/examples/city_scenario/messages/health_check_message.rb +21 -0
- data/examples/city_scenario/messages/health_status_message.rb +34 -0
- data/examples/city_scenario/messages/police_dispatch_message.rb +45 -0
- data/examples/city_scenario/messages/silent_alarm_message.rb +37 -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 -3
- data/examples/{09_dead_letter_queue_demo.rb → memory/02_dead_letter_queue_demo.rb} +10 -40
- data/examples/{01_point_to_point_orders.rb → memory/03_point_to_point_orders.rb} +1 -3
- data/examples/{02_publish_subscribe_events.rb → memory/04_publish_subscribe_events.rb} +1 -2
- data/examples/{03_many_to_many_chat.rb → memory/05_many_to_many_chat.rb} +1 -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} +1 -2
- data/examples/{06_custom_logger_example.rb → memory/08_custom_logger_demo.rb} +13 -14
- data/examples/{07_error_handling_scenarios.rb → memory/09_error_handling_demo.rb} +1 -4
- data/examples/{08_entity_addressing_basic.rb → memory/10_entity_addressing_basic.rb} +2 -8
- data/examples/{08_entity_addressing_with_filtering.rb → memory/11_entity_addressing_with_filtering.rb} +2 -6
- data/examples/{09_regex_filtering_microservices.rb → memory/12_regex_filtering_microservices.rb} +1 -2
- data/examples/{10_header_block_configuration.rb → memory/13_header_block_configuration.rb} +1 -6
- data/examples/{11_global_configuration_example.rb → memory/14_global_configuration_demo.rb} +17 -8
- data/examples/{show_logger.rb → memory/15_logger_demo.rb} +1 -2
- 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} +1 -5
- data/examples/redis/README.md +228 -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/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 +19 -12
- data/lib/smart_message/configuration.rb +2 -23
- data/lib/smart_message/dead_letter_queue.rb +1 -1
- data/lib/smart_message/logger.rb +15 -4
- data/lib/smart_message/messaging.rb +3 -62
- data/lib/smart_message/plugins.rb +6 -44
- data/lib/smart_message/serializer.rb +14 -0
- data/lib/smart_message/transport/base.rb +42 -8
- data/lib/smart_message/transport/memory_transport.rb +23 -4
- data/lib/smart_message/transport/redis_transport.rb +11 -0
- data/lib/smart_message/transport/stdout_transport.rb +28 -10
- data/lib/smart_message/transport.rb +33 -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 +145 -45
- data/docs/README.md +0 -57
- data/docs/serializers.md +0 -575
- 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
@@ -11,7 +11,7 @@
|
|
11
11
|
# - Administrative functions
|
12
12
|
# - Monitoring and statistics
|
13
13
|
|
14
|
-
require_relative '
|
14
|
+
require_relative '../../lib/smart_message'
|
15
15
|
require 'json'
|
16
16
|
require 'fileutils'
|
17
17
|
|
@@ -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)
|
@@ -193,12 +190,8 @@ rescue => e
|
|
193
190
|
puts "❌ Validation failed: #{e.message}"
|
194
191
|
|
195
192
|
# Manually add to DLQ
|
196
|
-
wrapper = SmartMessage::Wrapper::Base.new(
|
197
|
-
header: payment._sm_header,
|
198
|
-
payload: payment.encode
|
199
|
-
)
|
200
193
|
dlq.enqueue(
|
201
|
-
|
194
|
+
payment,
|
202
195
|
error: e.message,
|
203
196
|
transport: "ValidationLayer",
|
204
197
|
retry_count: 0
|
@@ -236,12 +229,8 @@ rescue => e
|
|
236
229
|
puts "❌ Publish failed: #{e.message}"
|
237
230
|
|
238
231
|
# Circuit breaker would normally handle this, but we'll add manually for demo
|
239
|
-
wrapper = SmartMessage::Wrapper::Base.new(
|
240
|
-
header: payment._sm_header,
|
241
|
-
payload: payment.encode
|
242
|
-
)
|
243
232
|
dlq.enqueue(
|
244
|
-
|
233
|
+
payment,
|
245
234
|
error: e.message,
|
246
235
|
transport: failing_transport.class.name,
|
247
236
|
retry_count: 1
|
@@ -263,12 +252,8 @@ order = OrderMessage.new(
|
|
263
252
|
total: 99.99
|
264
253
|
)
|
265
254
|
|
266
|
-
wrapper = SmartMessage::Wrapper::Base.new(
|
267
|
-
header: order._sm_header,
|
268
|
-
payload: order.encode
|
269
|
-
)
|
270
255
|
dlq.enqueue(
|
271
|
-
|
256
|
+
order,
|
272
257
|
error: "Gateway timeout after 30 seconds",
|
273
258
|
transport: "Redis",
|
274
259
|
retry_count: 3
|
@@ -282,12 +267,8 @@ notification = NotificationMessage.new(
|
|
282
267
|
channel: "sms"
|
283
268
|
)
|
284
269
|
|
285
|
-
wrapper = SmartMessage::Wrapper::Base.new(
|
286
|
-
header: notification._sm_header,
|
287
|
-
payload: notification.encode
|
288
|
-
)
|
289
270
|
dlq.enqueue(
|
290
|
-
|
271
|
+
notification,
|
291
272
|
error: "Rate limit exceeded: 429 Too Many Requests",
|
292
273
|
transport: "SMSGateway",
|
293
274
|
retry_count: 1
|
@@ -301,12 +282,8 @@ payment3 = PaymentMessage.new(
|
|
301
282
|
customer_id: "CUST-789"
|
302
283
|
)
|
303
284
|
|
304
|
-
wrapper = SmartMessage::Wrapper::Base.new(
|
305
|
-
header: payment3._sm_header,
|
306
|
-
payload: payment3.encode
|
307
|
-
)
|
308
285
|
dlq.enqueue(
|
309
|
-
|
286
|
+
payment3,
|
310
287
|
error: "Invalid merchant credentials",
|
311
288
|
transport: "StripeGateway",
|
312
289
|
retry_count: 0
|
@@ -461,17 +438,10 @@ temp_messages = []
|
|
461
438
|
puts " #{i + 1}. #{msg[:header][:message_class]} - #{msg[:timestamp]}"
|
462
439
|
end
|
463
440
|
|
464
|
-
#
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
header: header,
|
469
|
-
payload: msg[:payload]
|
470
|
-
)
|
471
|
-
dlq.enqueue(wrapper,
|
472
|
-
error: msg[:error],
|
473
|
-
retry_count: msg[:retry_count])
|
474
|
-
end
|
441
|
+
# Note: For demo purposes, we dequeued messages to show FIFO order.
|
442
|
+
# In a real application, you would typically replay them instead of manually re-enqueuing.
|
443
|
+
puts "\n📝 Messages were dequeued to demonstrate FIFO order."
|
444
|
+
puts " In production, use dlq.replay_batch() to properly restore and replay messages."
|
475
445
|
|
476
446
|
# ==============================================================================
|
477
447
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# This example demonstrates point-to-point messaging between an OrderService
|
7
7
|
# and a PaymentService. Each order gets processed by exactly one payment processor.
|
8
8
|
|
9
|
-
require_relative '
|
9
|
+
require_relative '../../lib/smart_message'
|
10
10
|
|
11
11
|
puts "=== SmartMessage Example: Point-to-Point Order Processing ==="
|
12
12
|
puts
|
@@ -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)
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# This example demonstrates publish-subscribe messaging where one event publisher
|
7
7
|
# sends notifications to multiple subscribers (email service, SMS service, audit logger).
|
8
8
|
|
9
|
-
require_relative '
|
9
|
+
require_relative '../../lib/smart_message'
|
10
10
|
|
11
11
|
puts "=== SmartMessage Example: Publish-Subscribe Event Notifications ==="
|
12
12
|
puts
|
@@ -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
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# can send messages to multiple chat rooms, and other agents receive and respond
|
8
8
|
# to messages based on their interests and capabilities.
|
9
9
|
|
10
|
-
require_relative '
|
10
|
+
require_relative '../../lib/smart_message'
|
11
11
|
|
12
12
|
puts "=== SmartMessage Example: Many-to-Many Distributed Chat ==="
|
13
13
|
puts
|
@@ -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)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# show_me.rb - Demonstrates the pretty_print method on SmartMessage instances
|
3
3
|
|
4
|
-
require_relative '
|
4
|
+
require_relative '../../lib/smart_message'
|
5
5
|
|
6
6
|
# Define a sample order message
|
7
7
|
class OrderMessage < SmartMessage::Base
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# in SmartMessage, showing different ways to subscribe to messages beyond
|
8
8
|
# the traditional self.process method.
|
9
9
|
|
10
|
-
require_relative '
|
10
|
+
require_relative '../../lib/smart_message'
|
11
11
|
|
12
12
|
puts "=== SmartMessage Proc and Block Handler Example ==="
|
13
13
|
puts
|
@@ -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
|
@@ -44,7 +44,7 @@
|
|
44
44
|
# 2. Configure it at the class level: logger SmartMessage::Logger::RailsLogger.new
|
45
45
|
# 3. All messages will be logged to your Rails application logs
|
46
46
|
|
47
|
-
require_relative '
|
47
|
+
require_relative '../../lib/smart_message'
|
48
48
|
require 'logger'
|
49
49
|
require 'json'
|
50
50
|
require 'fileutils'
|
@@ -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
|
@@ -466,16 +462,19 @@ class PriorityOrderService
|
|
466
462
|
end
|
467
463
|
|
468
464
|
def process_priority_order(order_data)
|
469
|
-
#
|
470
|
-
|
465
|
+
# Use class-level logger override for this specific processing
|
466
|
+
original_logger = OrderProcessingMessage.logger
|
467
|
+
OrderProcessingMessage.logger(@priority_logger)
|
471
468
|
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
469
|
+
begin
|
470
|
+
message = OrderProcessingMessage.new(**order_data, from: 'PriorityOrderService')
|
471
|
+
puts "⚡ Processing priority order with dedicated logger"
|
472
|
+
message.publish
|
473
|
+
message
|
474
|
+
ensure
|
475
|
+
# Restore original logger
|
476
|
+
OrderProcessingMessage.logger(original_logger)
|
477
|
+
end
|
479
478
|
end
|
480
479
|
end
|
481
480
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# These scenarios help developers understand SmartMessage's robust error handling
|
12
12
|
# and how to build resilient message-based systems.
|
13
13
|
|
14
|
-
require_relative '
|
14
|
+
require_relative '../../lib/smart_message'
|
15
15
|
|
16
16
|
puts "=== SmartMessage Example: Error Handling Scenarios ==="
|
17
17
|
puts
|
@@ -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
|
|
@@ -8,14 +8,14 @@
|
|
8
8
|
# - Instance-level addressing overrides
|
9
9
|
# - Gateway patterns
|
10
10
|
|
11
|
-
require_relative '
|
11
|
+
require_relative '../../lib/smart_message'
|
12
12
|
|
13
13
|
puts "🎯 SmartMessage Entity Addressing Demo"
|
14
14
|
puts "=" * 50
|
15
15
|
|
16
16
|
# Configure transport for demo
|
17
17
|
transport = SmartMessage::Transport.create(:stdout, loopback: true)
|
18
|
-
serializer = SmartMessage::Serializer::
|
18
|
+
serializer = SmartMessage::Serializer::Json.new
|
19
19
|
|
20
20
|
# =============================================================================
|
21
21
|
# Example 1: Point-to-Point Messaging
|
@@ -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)
|
@@ -9,14 +9,14 @@
|
|
9
9
|
# - Instance-level addressing overrides
|
10
10
|
# - Gateway patterns
|
11
11
|
|
12
|
-
require_relative '
|
12
|
+
require_relative '../../lib/smart_message'
|
13
13
|
|
14
14
|
puts "🎯 SmartMessage Entity Addressing & Filtering Demo"
|
15
15
|
puts "=" * 50
|
16
16
|
|
17
17
|
# Configure transport for demo
|
18
18
|
transport = SmartMessage::Transport.create(:stdout, loopback: true)
|
19
|
-
serializer = SmartMessage::Serializer::
|
19
|
+
serializer = SmartMessage::Serializer::Json.new
|
20
20
|
|
21
21
|
# =============================================================================
|
22
22
|
# Example 1: Entity-Aware Message Filtering
|
@@ -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)
|
data/examples/{09_regex_filtering_microservices.rb → memory/12_regex_filtering_microservices.rb}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# examples/09_regex_filtering_microservices.rb
|
3
3
|
|
4
|
-
require_relative '
|
4
|
+
require_relative '../../lib/smart_message'
|
5
5
|
|
6
6
|
# Example: Advanced Regex Filtering for Microservices Architecture
|
7
7
|
#
|
@@ -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
|
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# - Method 3: Instance-level overrides
|
8
8
|
# - Shortcut accessor methods for addressing
|
9
9
|
|
10
|
-
require_relative '
|
10
|
+
require_relative '../../lib/smart_message'
|
11
11
|
|
12
12
|
puts "🎯 SmartMessage Header Block Configuration Demo"
|
13
13
|
puts "=" * 50
|
@@ -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
|
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# system to set default logger, transport, and serializer for all message
|
8
8
|
# classes in your application.
|
9
9
|
|
10
|
-
require_relative '
|
10
|
+
require_relative '../../lib/smart_message'
|
11
11
|
|
12
12
|
puts "=== SmartMessage Global Configuration Example ==="
|
13
13
|
puts
|
@@ -59,7 +59,11 @@ class NotificationMessage < SmartMessage::Base
|
|
59
59
|
property :message
|
60
60
|
property :priority, default: 'normal'
|
61
61
|
|
62
|
-
#
|
62
|
+
# Explicitly use global configuration for demonstration
|
63
|
+
config do
|
64
|
+
transport SmartMessage::Transport.default
|
65
|
+
logger SmartMessage::Logger.default
|
66
|
+
end
|
63
67
|
|
64
68
|
def self.process(wrapper)
|
65
69
|
message_header, message_payload = wrapper.split
|
@@ -80,7 +84,11 @@ class OrderStatusMessage < SmartMessage::Base
|
|
80
84
|
property :status
|
81
85
|
property :customer_id
|
82
86
|
|
83
|
-
#
|
87
|
+
# Explicitly use global configuration for demonstration
|
88
|
+
config do
|
89
|
+
transport SmartMessage::Transport.default
|
90
|
+
logger SmartMessage::Logger.default
|
91
|
+
end
|
84
92
|
|
85
93
|
def self.process(wrapper)
|
86
94
|
message_header, message_payload = wrapper.split
|
@@ -98,14 +106,15 @@ class OrderStatusMessage < SmartMessage::Base
|
|
98
106
|
end
|
99
107
|
end
|
100
108
|
|
101
|
-
# Subscribe to messages to see them in action
|
102
|
-
NotificationMessage.subscribe
|
103
|
-
OrderStatusMessage.subscribe
|
104
|
-
|
105
109
|
puts " Message classes configured automatically!"
|
106
110
|
puts
|
107
111
|
|
108
|
-
#
|
112
|
+
# Subscribe to messages to see them in action (after configuration is complete)
|
113
|
+
# Message classes now explicitly use global configuration via config blocks
|
114
|
+
NotificationMessage.subscribe
|
115
|
+
OrderStatusMessage.subscribe
|
116
|
+
|
117
|
+
# Example 5: Creating and publishing messages
|
109
118
|
puts "4. Publishing Messages (using global configuration):"
|
110
119
|
|
111
120
|
notification = NotificationMessage.new(
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# Demonstrates the various features of the SmartMessage default logger
|
5
5
|
# and shows how applications can use the logger directly.
|
6
6
|
|
7
|
-
require_relative '
|
7
|
+
require_relative '../../lib/smart_message'
|
8
8
|
|
9
9
|
puts "=" * 80
|
10
10
|
puts "SmartMessage Logger Feature Demonstration"
|
@@ -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
|
|