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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -1
- data/Gemfile.lock +5 -5
- data/docs/core-concepts/architecture.md +5 -10
- data/docs/getting-started/examples.md +0 -12
- data/docs/getting-started/quick-start.md +4 -9
- data/docs/index.md +4 -4
- data/docs/reference/serializers.md +160 -488
- data/docs/reference/transports.md +1 -125
- data/docs/transports/redis-transport-comparison.md +215 -350
- data/docs/transports/redis-transport.md +3 -22
- data/examples/README.md +6 -9
- data/examples/city_scenario/README.md +1 -1
- data/examples/city_scenario/messages/emergency_911_message.rb +0 -1
- data/examples/city_scenario/messages/emergency_resolved_message.rb +0 -1
- data/examples/city_scenario/messages/fire_dispatch_message.rb +0 -1
- data/examples/city_scenario/messages/fire_emergency_message.rb +0 -1
- data/examples/city_scenario/messages/health_check_message.rb +0 -1
- data/examples/city_scenario/messages/health_status_message.rb +0 -1
- data/examples/city_scenario/messages/police_dispatch_message.rb +0 -1
- data/examples/city_scenario/messages/silent_alarm_message.rb +0 -1
- data/examples/memory/01_message_deduplication_demo.rb +0 -2
- data/examples/memory/02_dead_letter_queue_demo.rb +0 -3
- data/examples/memory/03_point_to_point_orders.rb +0 -2
- data/examples/memory/04_publish_subscribe_events.rb +0 -1
- data/examples/memory/05_many_to_many_chat.rb +0 -3
- data/examples/memory/07_proc_handlers_demo.rb +0 -1
- data/examples/memory/08_custom_logger_demo.rb +0 -4
- data/examples/memory/09_error_handling_demo.rb +0 -3
- data/examples/memory/10_entity_addressing_basic.rb +0 -6
- data/examples/memory/11_entity_addressing_with_filtering.rb +0 -4
- data/examples/memory/12_regex_filtering_microservices.rb +0 -1
- data/examples/memory/13_header_block_configuration.rb +0 -5
- data/examples/memory/14_global_configuration_demo.rb +0 -2
- data/examples/memory/15_logger_demo.rb +0 -1
- data/examples/memory/README.md +3 -3
- data/examples/redis/01_smart_home_iot_demo.rb +0 -4
- data/examples/redis/README.md +0 -2
- data/lib/smart_message/base.rb +19 -10
- data/lib/smart_message/configuration.rb +2 -23
- data/lib/smart_message/dead_letter_queue.rb +1 -1
- data/lib/smart_message/messaging.rb +3 -62
- data/lib/smart_message/plugins.rb +1 -42
- 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/registry.rb +0 -1
- data/lib/smart_message/transport/stdout_transport.rb +28 -10
- data/lib/smart_message/transport.rb +0 -1
- data/lib/smart_message/version.rb +1 -1
- metadata +2 -28
- data/docs/guides/redis-queue-getting-started.md +0 -697
- data/docs/guides/redis-queue-patterns.md +0 -889
- data/docs/guides/redis-queue-production.md +0 -1091
- data/docs/transports/redis-enhanced-transport.md +0 -524
- data/docs/transports/redis-queue-transport.md +0 -1304
- data/examples/redis_enhanced/README.md +0 -319
- data/examples/redis_enhanced/enhanced_01_basic_patterns.rb +0 -233
- data/examples/redis_enhanced/enhanced_02_fluent_api.rb +0 -331
- data/examples/redis_enhanced/enhanced_03_dual_publishing.rb +0 -281
- data/examples/redis_enhanced/enhanced_04_advanced_routing.rb +0 -419
- data/examples/redis_queue/01_basic_messaging.rb +0 -221
- data/examples/redis_queue/01_comprehensive_examples.rb +0 -508
- data/examples/redis_queue/02_pattern_routing.rb +0 -405
- data/examples/redis_queue/03_fluent_api.rb +0 -422
- data/examples/redis_queue/04_load_balancing.rb +0 -486
- data/examples/redis_queue/05_microservices.rb +0 -735
- data/examples/redis_queue/06_emergency_alerts.rb +0 -777
- data/examples/redis_queue/07_queue_management.rb +0 -587
- data/examples/redis_queue/README.md +0 -366
- data/examples/redis_queue/enhanced_01_basic_patterns.rb +0 -233
- data/examples/redis_queue/enhanced_02_fluent_api.rb +0 -331
- data/examples/redis_queue/enhanced_03_dual_publishing.rb +0 -281
- data/examples/redis_queue/enhanced_04_advanced_routing.rb +0 -419
- data/examples/redis_queue/redis_queue_architecture.svg +0 -148
- data/lib/smart_message/transport/redis_enhanced_transport.rb +0 -399
- data/lib/smart_message/transport/redis_queue_transport.rb +0 -555
@@ -137,12 +137,7 @@ Production-ready Redis pub/sub transport for distributed messaging.
|
|
137
137
|
- Configurable connection parameters
|
138
138
|
- Background message subscription threads
|
139
139
|
|
140
|
-
> **💡 Redis Transport
|
141
|
-
> - **Redis (Basic)** - Simple pub/sub for basic scenarios
|
142
|
-
> - **Redis Enhanced** - Pattern-based routing with backwards compatibility
|
143
|
-
> - **Redis Queue** - Persistent queues with load balancing
|
144
|
-
>
|
145
|
-
> See the [Redis Transport Comparison](../transports/redis-transport-comparison.md) for detailed differences and usage guidance.
|
140
|
+
> **💡 Redis Transport:** SmartMessage provides a Redis-based transport for production messaging using pub/sub channels. See the [Redis Transport documentation](../transports/redis-transport.md) for detailed usage guidance.
|
146
141
|
|
147
142
|
**Usage:**
|
148
143
|
|
@@ -173,7 +168,6 @@ class OrderMessage < SmartMessage::Base
|
|
173
168
|
url: 'redis://localhost:6379',
|
174
169
|
db: 1
|
175
170
|
)
|
176
|
-
serializer SmartMessage::Serializer::Json.new
|
177
171
|
end
|
178
172
|
|
179
173
|
def self.process(decoded_message)
|
@@ -250,7 +244,6 @@ redis_transport = SmartMessage::Transport.create(:redis,
|
|
250
244
|
[OrderMessage, PaymentMessage, ShippingMessage].each do |msg_class|
|
251
245
|
msg_class.config do
|
252
246
|
transport redis_transport
|
253
|
-
serializer SmartMessage::Serializer::Json.new
|
254
247
|
end
|
255
248
|
|
256
249
|
# Subscribe to each message type (creates separate Redis subscriptions)
|
@@ -292,7 +285,6 @@ class ProductionMessage < SmartMessage::Base
|
|
292
285
|
reconnect_attempts: 10,
|
293
286
|
reconnect_delay: 5
|
294
287
|
)
|
295
|
-
serializer SmartMessage::Serializer::Json.new
|
296
288
|
logger Logger.new(STDOUT)
|
297
289
|
end
|
298
290
|
end
|
@@ -309,7 +301,6 @@ class TestMessage < SmartMessage::Base
|
|
309
301
|
db: 15, # Use separate database for tests
|
310
302
|
auto_subscribe: true
|
311
303
|
)
|
312
|
-
serializer SmartMessage::Serializer::Json.new
|
313
304
|
end
|
314
305
|
end
|
315
306
|
|
@@ -320,120 +311,6 @@ def setup
|
|
320
311
|
end
|
321
312
|
```
|
322
313
|
|
323
|
-
### Redis Enhanced Transport
|
324
|
-
|
325
|
-
Advanced Redis transport with intelligent pattern-based routing and RabbitMQ-style capabilities.
|
326
|
-
|
327
|
-
**Features:**
|
328
|
-
- Pattern-based subscriptions with wildcard support (`*` matching)
|
329
|
-
- Dual channel publishing for backwards compatibility
|
330
|
-
- Fluent API for building complex subscription patterns
|
331
|
-
- Enhanced routing with 3-part channel names: `message_type.from.to`
|
332
|
-
- Convenience methods for common routing patterns
|
333
|
-
- Service-oriented messaging patterns
|
334
|
-
|
335
|
-

|
336
|
-
|
337
|
-
**Usage:**
|
338
|
-
|
339
|
-
```ruby
|
340
|
-
# Create enhanced transport
|
341
|
-
transport = SmartMessage::Transport::RedisEnhancedTransport.new(
|
342
|
-
url: 'redis://localhost:6379',
|
343
|
-
db: 0,
|
344
|
-
auto_subscribe: true
|
345
|
-
)
|
346
|
-
|
347
|
-
# Configure message with enhanced transport
|
348
|
-
class OrderMessage < SmartMessage::Base
|
349
|
-
from 'e-commerce-api'
|
350
|
-
to 'order-processor'
|
351
|
-
|
352
|
-
transport transport
|
353
|
-
serializer SmartMessage::Serializer::Json.new
|
354
|
-
|
355
|
-
property :order_id, required: true
|
356
|
-
property :amount, required: true
|
357
|
-
end
|
358
|
-
|
359
|
-
# Pattern-based subscriptions
|
360
|
-
transport.subscribe_pattern("ordermessage.*.*") # All order messages
|
361
|
-
transport.subscribe_pattern("*.payment_gateway.*") # All from payment gateway
|
362
|
-
transport.subscribe_to_recipient('order-processor') # Convenience method
|
363
|
-
transport.subscribe_to_alerts # Emergency patterns
|
364
|
-
|
365
|
-
# Fluent API subscriptions
|
366
|
-
transport.where.from('web-app').to('user-service').subscribe
|
367
|
-
transport.where.type('OrderMessage').from('api').subscribe
|
368
|
-
transport.where.from('monitoring').subscribe
|
369
|
-
|
370
|
-
# Publishing (goes to BOTH channels for compatibility)
|
371
|
-
order = OrderMessage.new(order_id: 'ORD-123', amount: 99.99)
|
372
|
-
order.publish
|
373
|
-
# Publishes to:
|
374
|
-
# - "OrderMessage" (original format)
|
375
|
-
# - "ordermessage.e_commerce_api.order_processor" (enhanced format)
|
376
|
-
```
|
377
|
-
|
378
|
-
**Pattern Wildcards:**
|
379
|
-
- `*` - Matches exactly one segment
|
380
|
-
- `ordermessage.*.*` - All order messages regardless of from/to
|
381
|
-
- `*.payment_service.*` - All messages from payment service
|
382
|
-
- `*.*.order_processor` - All messages to order processor
|
383
|
-
|
384
|
-
**Convenience Methods:**
|
385
|
-
```ruby
|
386
|
-
transport.subscribe_to_recipient('service-name') # *.*.service-name
|
387
|
-
transport.subscribe_from_sender('api-gateway') # *.api-gateway.*
|
388
|
-
transport.subscribe_to_type('OrderMessage') # ordermessage.*.*
|
389
|
-
transport.subscribe_to_alerts # Multiple alert patterns
|
390
|
-
transport.subscribe_to_broadcasts # *.*.broadcast
|
391
|
-
```
|
392
|
-
|
393
|
-
**Fluent API:**
|
394
|
-
```ruby
|
395
|
-
# Single conditions
|
396
|
-
transport.where.from('api').subscribe # *.api.*
|
397
|
-
transport.where.to('database').subscribe # *.*.database
|
398
|
-
transport.where.type('LogMessage').subscribe # logmessage.*.*
|
399
|
-
|
400
|
-
# Combined conditions
|
401
|
-
transport.where.from('web').to('api').subscribe # *.web.api
|
402
|
-
transport.where.type('Order').from('shop').subscribe # order.shop.*
|
403
|
-
```
|
404
|
-
|
405
|
-
**Options:**
|
406
|
-
- `url` (String): Redis connection URL (default: 'redis://localhost:6379')
|
407
|
-
- `db` (Integer): Redis database number (default: 0)
|
408
|
-
- `auto_subscribe` (Boolean): Automatically start subscriber threads (default: true)
|
409
|
-
- `reconnect_attempts` (Integer): Connection retry attempts (default: 5)
|
410
|
-
- `reconnect_delay` (Integer): Delay between retries in seconds (default: 1)
|
411
|
-
|
412
|
-
**Backwards Compatibility:**
|
413
|
-
|
414
|
-
The Enhanced Transport maintains full backwards compatibility with the basic Redis transport by publishing to both channel formats:
|
415
|
-
|
416
|
-
```ruby
|
417
|
-
# Enhanced transport publishes to BOTH:
|
418
|
-
# 1. "OrderMessage" (basic format - for backwards compatibility)
|
419
|
-
# 2. "ordermessage.from_service.to_service" (enhanced format - for pattern matching)
|
420
|
-
|
421
|
-
# Basic Redis transport can still subscribe to "OrderMessage"
|
422
|
-
# Enhanced transport can use patterns on the enhanced format
|
423
|
-
```
|
424
|
-
|
425
|
-
**Use Cases:**
|
426
|
-
- Microservices architectures requiring sophisticated routing
|
427
|
-
- Migration from basic Redis transport (maintains compatibility)
|
428
|
-
- Development environments needing flexible message routing
|
429
|
-
- Applications requiring RabbitMQ-style patterns without RabbitMQ setup
|
430
|
-
- Service-to-service communication with intelligent filtering
|
431
|
-
|
432
|
-
**Performance:**
|
433
|
-
- Minimal overhead over basic Redis transport
|
434
|
-
- Client-side pattern matching (slightly higher CPU usage)
|
435
|
-
- Dual publishing increases Redis network traffic by ~2x
|
436
|
-
- Excellent performance for most production scenarios
|
437
314
|
|
438
315
|
## Transport Interface
|
439
316
|
|
@@ -533,7 +410,6 @@ class OrderMessage < SmartMessage::Base
|
|
533
410
|
# All instances use this transport by default
|
534
411
|
config do
|
535
412
|
transport SmartMessage::Transport.create(:memory, auto_process: true)
|
536
|
-
serializer SmartMessage::Serializer::Json.new
|
537
413
|
end
|
538
414
|
end
|
539
415
|
```
|