public SqsTransportInfrastructure(ReadOnlySettings settings) { this.settings = settings; messageMetadataRegistry = this.settings.Get <MessageMetadataRegistry>(); configuration = new TransportConfiguration(settings); if (settings.HasSetting(SettingsKeys.DisableNativePubSub)) { OutboundRoutingPolicy = new OutboundRoutingPolicy(OutboundRoutingType.Unicast, OutboundRoutingType.Unicast, OutboundRoutingType.Unicast); } else { OutboundRoutingPolicy = new OutboundRoutingPolicy(OutboundRoutingType.Unicast, OutboundRoutingType.Multicast, OutboundRoutingType.Unicast); } try { sqsClient = configuration.SqsClientFactory(); } catch (AmazonClientException e) { var message = "Unable to configure the SQS client. Make sure the environment variables for AWS_REGION, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set or the client factory configures the created client accordingly"; Logger.Error(message, e); throw new Exception(message, e); } try { snsClient = configuration.SnsClientFactory(); } catch (AmazonClientException e) { var message = "Unable to configure the SNS client. Make sure the environment variables for AWS_REGION, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set or the client factory configures the created client accordingly"; Logger.Error(message, e); throw new Exception(message, e); } try { if (!string.IsNullOrEmpty(settings.GetOrDefault <string>(SettingsKeys.S3BucketForLargeMessages))) { s3Client = configuration.S3ClientFactory(); } } catch (AmazonClientException e) { var message = "Unable to configure the S3 client. Make sure the environment variables for AWS_REGION, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set or the client factory configures the created client accordingly"; Logger.Error(message, e); throw new Exception(message, e); } queueCache = new QueueCache(sqsClient, configuration); topicCache = new TopicCache(snsClient, messageMetadataRegistry, configuration); }
internal SqlServerTransportInfrastructure(string catalog, SettingsHolder settings, string connectionString, Func <string> localAddress, Func <LogicalAddress> logicalAddress, bool isEncrypted) { this.settings = settings; this.connectionString = connectionString; this.localAddress = localAddress; this.logicalAddress = logicalAddress; this.isEncrypted = isEncrypted; if (settings.HasSetting(SettingsKeys.DisableNativePubSub)) { OutboundRoutingPolicy = new OutboundRoutingPolicy(OutboundRoutingType.Unicast, OutboundRoutingType.Unicast, OutboundRoutingType.Unicast); } else { OutboundRoutingPolicy = new OutboundRoutingPolicy(OutboundRoutingType.Unicast, OutboundRoutingType.Multicast, OutboundRoutingType.Unicast); } settings.TryGet(SettingsKeys.DefaultSchemaSettingsKey, out string defaultSchemaOverride); var queueSchemaSettings = settings.GetOrDefault <QueueSchemaAndCatalogSettings>(); addressTranslator = new QueueAddressTranslator(catalog, "dbo", defaultSchemaOverride, queueSchemaSettings); tableBasedQueueCache = new TableBasedQueueCache(addressTranslator, !isEncrypted); connectionFactory = CreateConnectionFactory(); //Configure the schema and catalog for logical endpoint-based routing var schemaAndCatalogSettings = settings.GetOrCreate <EndpointSchemaAndCatalogSettings>(); settings.GetOrCreate <EndpointInstances>().AddOrReplaceInstances("SqlServer", schemaAndCatalogSettings.ToEndpointInstances()); var pubSubSettings = settings.GetOrCreate <SubscriptionSettings>(); var subscriptionTableName = pubSubSettings.SubscriptionTable.Qualify(defaultSchemaOverride ?? "dbo", catalog); // necessary evil for acceptance tests if (settings.TryGet <Action <string> >(SettingsKeys.SubscriptionTableQuotedQualifiedNameSetter, out var action)) { action(subscriptionTableName.QuotedQualifiedName); } subscriptionStore = new PolymorphicSubscriptionStore(new SubscriptionTable(subscriptionTableName.QuotedQualifiedName, connectionFactory)); var timeToCacheSubscriptions = pubSubSettings.TimeToCacheSubscriptions; if (timeToCacheSubscriptions.HasValue) { subscriptionStore = new CachedSubscriptionStore(subscriptionStore, timeToCacheSubscriptions.Value); } var subscriptionTableCreator = new SubscriptionTableCreator(subscriptionTableName, connectionFactory); settings.Set(subscriptionTableCreator); }
internal SqlServerTransportInfrastructure(string catalog, SettingsHolder settings, string connectionString, Func <string> localAddress, Func <LogicalAddress> logicalAddress) { this.settings = settings; this.connectionString = connectionString; this.localAddress = localAddress; this.logicalAddress = logicalAddress; if (settings.HasSetting(SettingsKeys.DisableNativePubSub)) { OutboundRoutingPolicy = new OutboundRoutingPolicy(OutboundRoutingType.Unicast, OutboundRoutingType.Unicast, OutboundRoutingType.Unicast); } else { OutboundRoutingPolicy = new OutboundRoutingPolicy(OutboundRoutingType.Unicast, OutboundRoutingType.Multicast, OutboundRoutingType.Unicast); } settings.TryGet(SettingsKeys.DefaultSchemaSettingsKey, out string defaultSchemaOverride); var queueSchemaSettings = settings.GetOrDefault <QueueSchemaAndCatalogSettings>(); addressTranslator = new QueueAddressTranslator(catalog, "dbo", defaultSchemaOverride, queueSchemaSettings); tableBasedQueueCache = new TableBasedQueueCache(addressTranslator); connectionFactory = CreateConnectionFactory(); //Configure the schema and catalog for logical endpoint-based routing var schemaAndCatalogSettings = settings.GetOrCreate <EndpointSchemaAndCatalogSettings>(); settings.GetOrCreate <EndpointInstances>().AddOrReplaceInstances("SqlServer", schemaAndCatalogSettings.ToEndpointInstances()); //Needs to be invoked here and not when configuring the receiving infrastructure because the EnableMigrationMode flag has to be set up before feature component is initialized. HandleTimeoutManagerCompatibilityMode(); var pubSubSettings = settings.GetOrCreate <SubscriptionSettings>(); var subscriptionTableName = pubSubSettings.SubscriptionTable.Qualify(defaultSchemaOverride ?? "dbo", catalog); subscriptionStore = new PolymorphicSubscriptionStore(new SubscriptionTable(subscriptionTableName.QuotedQualifiedName, connectionFactory)); var timeToCacheSubscriptions = pubSubSettings.TimeToCacheSubscriptions; if (timeToCacheSubscriptions.HasValue) { subscriptionStore = new CachedSubscriptionStore(subscriptionStore, timeToCacheSubscriptions.Value); } var subscriptionTableCreator = new SubscriptionTableCreator(subscriptionTableName, connectionFactory); settings.Set(subscriptionTableCreator); }
private static string GetDestinationKind(MessageIntentEnum intentValue, OutboundRoutingPolicy routingPolicy) { switch (intentValue) { case MessageIntentEnum.Send: return(ConvertPolicyToKind(routingPolicy.Sends)); case MessageIntentEnum.Publish: return(ConvertPolicyToKind(routingPolicy.Publishes)); case MessageIntentEnum.Subscribe: return(ConvertPolicyToKind(routingPolicy.Sends)); case MessageIntentEnum.Unsubscribe: return(ConvertPolicyToKind(routingPolicy.Sends)); case MessageIntentEnum.Reply: return(ConvertPolicyToKind(routingPolicy.Replies)); default: return(null); } }
private static string GetDestinationKind(MessageIntentEnum intentValue, OutboundRoutingPolicy routingPolicy) => intentValue switch {