public MessageDispatcher(QueueAddressTranslator addressTranslator, IMulticastToUnicastConverter multicastToUnicastConverter, TableBasedQueueCache tableBasedQueueCache, IDelayedMessageStore delayedMessageTable, SqlConnectionFactory connectionFactory)
 {
     this.addressTranslator           = addressTranslator;
     this.multicastToUnicastConverter = multicastToUnicastConverter;
     this.tableBasedQueueCache        = tableBasedQueueCache;
     this.delayedMessageTable         = delayedMessageTable;
     this.connectionFactory           = connectionFactory;
 }
 public QueueCreator(SqlConnectionFactory connectionFactory, QueueAddressTranslator addressTranslator,
                     CanonicalQueueAddress delayedQueueAddress, bool createMessageBodyColumn = false)
 {
     this.connectionFactory       = connectionFactory;
     this.addressTranslator       = addressTranslator;
     this.delayedQueueAddress     = delayedQueueAddress;
     this.createMessageBodyColumn = createMessageBodyColumn;
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        internal SqlServerTransportInfrastructure(SqlServerTransport transport, HostSettings hostSettings, QueueAddressTranslator addressTranslator, bool isEncrypted)
        {
            this.transport         = transport;
            this.hostSettings      = hostSettings;
            this.isEncrypted       = isEncrypted;
            this.addressTranslator = addressTranslator;

            tableBasedQueueCache = new TableBasedQueueCache(addressTranslator, !isEncrypted);
            connectionFactory    = CreateConnectionFactory();
        }
        public static SortingResult SortAndDeduplicate(this IEnumerable <UnicastTransportOperation> source, QueueAddressTranslator addressTranslator)
        {
            Dictionary <DeduplicationKey, UnicastTransportOperation> isolatedDispatch = null;
            Dictionary <DeduplicationKey, UnicastTransportOperation> defaultDispatch  = null;

            foreach (var operation in source)
            {
                var destination      = addressTranslator.Parse(operation.Destination).Address;
                var messageId        = operation.Message.MessageId;
                var deduplicationKey = new DeduplicationKey(messageId, destination);

                if (operation.RequiredDispatchConsistency == DispatchConsistency.Default)
                {
                    defaultDispatch = defaultDispatch ?? new Dictionary <DeduplicationKey, UnicastTransportOperation>(DeduplicationKey.MessageIdDestinationComparer);
                    defaultDispatch[deduplicationKey] = operation;
                }
                else if (operation.RequiredDispatchConsistency == DispatchConsistency.Isolated)
                {
                    isolatedDispatch = isolatedDispatch ?? new Dictionary <DeduplicationKey, UnicastTransportOperation>(DeduplicationKey.MessageIdDestinationComparer);
                    isolatedDispatch[deduplicationKey] = operation;
                }
            }

            return(new SortingResult(defaultDispatch?.Values, isolatedDispatch?.Values));
        }
Exemple #6
0
 public QueueCreator(SqlConnectionFactory connectionFactory, QueueAddressTranslator addressTranslator, bool createMessageBodyColumn = false)
 {
     this.connectionFactory       = connectionFactory;
     this.addressTranslator       = addressTranslator;
     this.createMessageBodyColumn = createMessageBodyColumn;
 }
 public TableBasedQueueCache(QueueAddressTranslator addressTranslator, bool isStreamSupported)
 {
     this.addressTranslator = addressTranslator;
     this.isStreamSupported = isStreamSupported;
 }