# AsyncCorrelator Configuration # Configuration for asynchronous request-response correlation system import Config # Configure AsyncCorrelator instances per upstream network config :da_product_app, AsyncCorrelator, networks: %{ # High-volume Visa network with multiple correlator instances :visa_network => %{ enabled: true, instance_count: 3, load_balance_strategy: :round_robin, correlation_timeout: 30_000, max_pending_requests: 1000, correlation_field: 11, # STAN connection_config: %{ connect_timeout: 5_000, keepalive: true, retry_attempts: 3 } }, # High-volume MasterCard network :mastercard_network => %{ enabled: true, instance_count: 2, load_balance_strategy: :least_loaded, correlation_timeout: 25_000, max_pending_requests: 800, correlation_field: 11, connection_config: %{ connect_timeout: 5_000, keepalive: true, retry_attempts: 3 } }, # Lower volume networks use single instance :amex_network => %{ enabled: true, instance_count: 1, load_balance_strategy: :round_robin, correlation_timeout: 20_000, max_pending_requests: 200, correlation_field: 37, # RRN for AmEx connection_config: %{ connect_timeout: 3_000, keepalive: false, retry_attempts: 2 } }, :discover_network => %{ enabled: true, instance_count: 1, load_balance_strategy: :round_robin, correlation_timeout: 20_000, max_pending_requests: 200, correlation_field: 11, connection_config: %{ connect_timeout: 3_000, keepalive: false, retry_attempts: 2 } } } # Configure which channels should use async correlation config :da_product_app, :async_correlation_channels, [ # Primary POS channel uses async correlation for high throughput 8583, # ATM channel also benefits from async correlation 8584 ] # Global AsyncCorrelator settings config :da_product_app, :async_correlator_global, %{ # Health check interval for correlator managers health_check_interval: 10_000, # Statistics collection interval statistics_interval: 30_000, # Connection recovery settings connection_recovery: %{ base_retry_delay: 1_000, max_retry_delay: 10_000, max_retry_attempts: 10, exponential_backoff: true }, # Monitoring and alerting thresholds monitoring: %{ max_correlation_time: 30_000, error_rate_threshold: 0.05, # 5% error rate connection_loss_alert_threshold: 3, pending_requests_alert_threshold: 900 }, # Performance tuning performance: %{ tcp_buffer_size: 65536, tcp_nodelay: true, process_priority: :high, scheduler_utilization_threshold: 0.8 } } # Enhanced processor pipeline configurations with async correlation config :da_product_app, :channels, %{ # Update primary POS channel to use async correlation 8583 => %{ name: "primary_iso8583", packager: DaProductApp.MercuryISO8583.Packagers.ISO87BPackager, protocol: DaProductApp.Switch.EnhancedProtocol, max_connections: 100, timeout: 30_000, transformations: [], validation_rules: :standard, header_config: %{ enabled: true, type: :base1, encoding: :bcd, pattern: "6000782000", length: 5, source_address_offset: 2, source_address_length: 2, dest_address_offset: 4, dest_address_length: 2 }, processors: [ # 1. Validation - Strict mode with comprehensive checks {DaProductApp.MercuryISO8583.Processors.ValidationProcessor, %{ allowed_mtis: ["0200", "0220", "0400", "0420", "0800", "0810"] }}, # 2. Enrichment - Add all metadata and trace numbers {DaProductApp.MercuryISO8583.Processors.EnrichmentProcessor, %{ timezone: "America/New_York" }}, # 3. Routing - ASYNC CORRELATION MODE for high throughput with field-based routing (YSP + Mastercard MPGS) {DaProductApp.MercuryISO8583.Processors.RoutingProcessor, %{ "routing_mode" => "field_based_routing", "routing_execution_mode" => "async_correlation", # Enable async correlation "async_correlator_instances" => 3, # Number of correlator instances per network # Mastercard MPGS routing (highest priority - check DE24 first) "field_routes" => %{ "24" => %{ "782" => "ysp_plain", # YSP messages with DE24=782 route to YSP plain network "784" => "mastercard_mpgs_sandbox" # Mastercard MPGS messages with DE24=784 route to simulator } }, # BIN-based routing (fallback for card transactions) "bin_routes" => %{ "4" => "visa_network", "5" => "mastercard_network", "2" => "mastercard_network", "3" => "amex_network", "6011" => "discover_network", "65" => "discover_network" }, "default_route" => "generic_processor", "reversal_route" => "reversal_processor", "admin_route" => "admin_processor", "no_pan_fallback_route" => "generic_processor", "terminal_routes" => %{ "12345678" => "terminal_specific_processor", "87654321" => "another_terminal_processor" }, "enable_load_balancing" => true, "failover_enabled" => true, "failover_networks" => ["backup_processor", "generic_processor"] }} ] }, # ATM channel with async correlation for high-volume ATM networks 8584 => %{ name: "secondary_iso8583", packager: DaProductApp.MercuryISO8583.Packagers.ISO87BPackager, protocol: DaProductApp.Switch.EnhancedProtocol, max_connections: 50, timeout: 15_000, transformations: [:normalize_amounts], validation_rules: :strict, header_config: %{ enabled: true, type: :base, encoding: :bcd, pattern: "123456", length: 3 }, processors: [ # 1. Basic validation {DaProductApp.MercuryISO8583.Processors.ValidationProcessor, %{ allowed_mtis: ["0200", "0400", "0800"] }}, # 2. Basic enrichment {DaProductApp.MercuryISO8583.Processors.EnrichmentProcessor, %{ timezone: "UTC" }}, # 3. Async correlation routing for ATM networks {DaProductApp.MercuryISO8583.Processors.RoutingProcessor, %{ "routing_mode" => "card_type", "routing_execution_mode" => "async_correlation", # Enable async for ATM too "async_correlator_instances" => 2, # Fewer instances for ATM "visa_network" => "visa_atm_network", "mastercard_network" => "mc_atm_network", "default_route" => "atm_processor", "enable_load_balancing" => false, "failover_enabled" => true }} ] }, # Test channel - keep synchronous for testing 8585 => %{ name: "test_channel", packager: DaProductApp.MercuryISO8583.Packagers.ISO87BPackager, protocol: DaProductApp.Switch.EnhancedProtocol, max_connections: 10, timeout: 10_000, transformations: [:add_local_timestamp], validation_rules: :lenient, header_config: %{ enabled: false, type: :base, encoding: :hex }, processors: [ # Keep synchronous routing for test environment {DaProductApp.MercuryISO8583.Processors.RoutingProcessor, %{ "routing_mode" => "manual", "routing_execution_mode" => "synchronous", # Synchronous for testing "route_overrides" => %{ {:any, :any} => "test_network" }, "default_route" => "test_network", "enable_load_balancing" => false, "failover_enabled" => false }} ] } }