using System; using Svrnty.CQRS.Events.Abstractions.Subscriptions; namespace Svrnty.CQRS.Events.Abstractions.Streaming; /// /// Configuration for subscribing to events from a remote stream in another service. /// /// /// /// Remote streams allow a service to consume events published by another service /// via an external message broker (RabbitMQ, Kafka, etc.). /// /// /// Example Scenario: /// Service A publishes "user-service.events" to RabbitMQ. /// Service B subscribes to "user-service.events" as a remote stream. /// /// public interface IRemoteStreamConfiguration { /// /// Gets the name of the remote stream (typically the exchange/topic name). /// /// /// Example: "user-service.events", "orders.events" /// string StreamName { get; } /// /// Gets or sets the provider type for the remote stream. /// /// /// Supported values: "RabbitMQ", "Kafka", "AzureServiceBus", "AwsSns" /// string ProviderType { get; set; } /// /// Gets or sets the connection string for the remote message broker. /// string ConnectionString { get; set; } /// /// Gets or sets the subscription mode for consuming events. /// /// /// /// BroadcastEach consumer gets all events /// ExclusiveOnly one consumer gets each event /// ConsumerGroupLoad-balanced across group members /// /// Default: ConsumerGroup (recommended for scalability) /// SubscriptionMode Mode { get; set; } /// /// Gets or sets whether to automatically create the necessary topology (queues, bindings). /// /// /// Default: true /// Set to false if topology is managed externally. /// bool AutoDeclareTopology { get; set; } /// /// Gets or sets the prefetch count for consumer-side buffering. /// /// /// Higher values increase throughput but use more memory. /// Default: 10 /// int PrefetchCount { get; set; } /// /// Gets or sets the acknowledgment mode for consumed messages. /// /// /// /// AutoAutomatic acknowledgment after handler completion /// ManualExplicit acknowledgment required /// /// Default: Auto /// AcknowledgmentMode AcknowledgmentMode { get; set; } /// /// Gets or sets the maximum number of redelivery attempts before dead-lettering. /// /// /// Default: 3 /// Set to 0 to disable dead-lettering (messages discarded on failure). /// int MaxRedeliveryAttempts { get; set; } /// /// Validates the configuration. /// /// Thrown if the configuration is invalid. void Validate(); } /// /// Acknowledgment mode for remote stream consumption. /// public enum AcknowledgmentMode { /// /// Automatic acknowledgment after the event handler completes successfully. /// /// /// If the handler throws an exception, the message is nacked and requeued. /// Auto, /// /// Manual acknowledgment required via explicit AcknowledgeAsync() call. /// /// /// Provides more control but requires explicit acknowledgment in handlers. /// Manual }