Ejemplo n.º 1
0
    public Bridge(string leftName, string rightName, bool autoCreateQueues, string autoCreateQueuesIdentity, EndpointInstances endpointInstances, ISubscriptionStorage subscriptionStorage, IDistributionPolicy distributionPolicy, string poisonQueue, Action <TransportExtensions <TLeft> > leftCustomization, Action <TransportExtensions <TRight> > rightCustomization, int?maximumConcurrency)
    {
        this.endpointInstances   = endpointInstances;
        this.subscriptionStorage = subscriptionStorage;
        publishRouter            = new PublishRouter(subscriptionStorage, distributionPolicy);
        sendRouter  = new SendRouter(endpointInstances, distributionPolicy);
        replyRouter = new ReplyRouter();

        leftConfig = RawEndpointConfiguration.Create(leftName, (context, _) => Forward(context, rightStartable, rightSubscribeRouter), poisonQueue);
        var leftTransport = leftConfig.UseTransport <TLeft>();

        leftTransport.GetSettings().Set("errorQueue", poisonQueue);
        leftCustomization?.Invoke(leftTransport);
        if (autoCreateQueues)
        {
            leftConfig.AutoCreateQueue(autoCreateQueuesIdentity);
        }

        rightConfig = RawEndpointConfiguration.Create(rightName, (context, _) => Forward(context, leftStartable, leftSubscribeRouter), poisonQueue);
        var rightTransport = rightConfig.UseTransport <TRight>();

        rightTransport.GetSettings().Set("errorQueue", poisonQueue);
        rightCustomization?.Invoke(rightTransport);
        if (autoCreateQueues)
        {
            rightConfig.AutoCreateQueue(autoCreateQueuesIdentity);
        }

        if (maximumConcurrency.HasValue)
        {
            leftConfig.LimitMessageProcessingConcurrencyTo(1);
            rightConfig.LimitMessageProcessingConcurrencyTo(1);
        }
    }
        static void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings, TransportTransactionMode transportTransactionMode)
        {
            var transport = endpointConfig.UseTransport <LearningTransport>();

            transport.StorageDirectory(Environment.ExpandEnvironmentVariables(transportSettings.ConnectionString));
            transport.Transactions(transportTransactionMode);
        }
        public override void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings)
        {
            var transport = endpointConfig.UseTransport <LearningTransport>();

            transport.StorageDirectory(transportSettings.ConnectionString);
            transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
        }
Ejemplo n.º 4
0
        public override void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings)
        {
            var transport = endpointConfig.UseTransport <SqlServerTransport>();

            ConfigureConnection(transport, transportSettings);
            transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
        }
Ejemplo n.º 5
0
        static void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings)
        {
            var transport = endpointConfig.UseTransport <AzureStorageQueueTransport>();

            transport.ApplyHacksForNsbRaw();
            ConfigureTransport(transport, transportSettings);
        }
Ejemplo n.º 6
0
        static TransportExtensions <MsmqTransport> CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings, TransportTransactionMode transportTransactionMode)
        {
            var transport = endpointConfig.UseTransport <MsmqTransport>();

            transport.Transactions(transportTransactionMode);
            return(transport);
        }
Ejemplo n.º 7
0
        public override void CustomizeForAuditIngestion(RawEndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
        {
            var transport = endpointConfiguration.UseTransport <AzureServiceBusTransport>();

            CustomizeEndpoint(transport, transportSettings);

            transport.ConfigureTransport(transportSettings, TransportTransactionMode.ReceiveOnly);
        }
Ejemplo n.º 8
0
        public override void CustomizeForReturnToSenderIngestion(RawEndpointConfiguration endpointConfiguration, TransportSettings transportSettings)
        {
            var transport = endpointConfiguration.UseTransport <AzureServiceBusTransport>();

            CustomizeEndpoint(transport, transportSettings);

            transport.ConfigureTransport(transportSettings, TransportTransactionMode.SendsAtomicWithReceive);
        }
        public void ConfigureDestinationTransport <TDestination>(
            Action <TransportExtensions <TDestination> > configureDestinationTransport = null)
            where TDestination : TransportDefinition, new()
        {
            var transport = _destinationEndpointConfiguration.UseTransport <TDestination>();

            configureDestinationTransport?.Invoke(transport);
        }
        public override void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings)
        {
            var transport = endpointConfig.UseTransport <AzureServiceBusTransport>();

            transport.UseEndpointOrientedTopology();
            transport.ApplyHacksForNsbRaw();

            transport.ConfigureTransport(transportSettings);
        }
Ejemplo n.º 11
0
        static void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings, TransportTransactionMode transactionMode)
        {
#pragma warning disable 618
            var transport = endpointConfig.UseTransport <AzureServiceBusTransport>();
#pragma warning restore 618
            transport.UseEndpointOrientedTopology();
            transport.ApplyHacksForNsbRaw();

            transport.ConfigureTransport(transportSettings, transactionMode);
        }
Ejemplo n.º 12
0
        public override void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings)
        {
            var transport = endpointConfig.UseTransport <AzureServiceBusTransport>();

            transport.ApplyHacksForNsbRaw();

            transport.UseForwardingTopology();
            transport.Sanitization().UseStrategy <ValidateAndHashIfNeeded>();
            transport.ConfigureTransport(transportSettings);
        }
        void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings, TransportTransactionMode transactionMode)
        {
#pragma warning disable 618
            var transport = endpointConfig.UseTransport <AzureServiceBusTransport>();
#pragma warning restore 618
            transport.ApplyHacksForNsbRaw();

            transport.UseForwardingTopology();
            transport.Sanitization().UseStrategy <ValidateAndHashIfNeeded>();
            transport.ConfigureTransport(transportSettings, transactionMode);
        }
        public void ConfigureOutboxTransport <TOutbox>(
            Action <TransportExtensions <TOutbox> > configureOutboxTransport = null)
            where TOutbox : TransportDefinition, new()
        {
            var outboxTransport = _outboxEndpointConfiguration.UseTransport <TOutbox>();

            configureOutboxTransport?.Invoke(outboxTransport);

            var forwarderTransport = _forwarderEndpointConfiguration.UseTransport <TOutbox>();

            configureOutboxTransport?.Invoke(forwarderTransport);
            // Prevent distributed transactions with the destination transport
            forwarderTransport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
        }
Ejemplo n.º 15
0
        public override void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings)
        {
            var transport = endpointConfig.UseTransport <SqlServerTransport>();

            ConfigureConnection(transport, transportSettings);
            endpointConfig.Settings.Set("SqlServer.DisableDelayedDelivery", true);

            var sendOnlyEndpoint = transport.GetSettings().GetOrDefault <bool>("Endpoint.SendOnly");

            if (!sendOnlyEndpoint)
            {
                transport.NativeDelayedDelivery().DisableTimeoutManagerCompatibility();
            }
            transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
        }
        static void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings, TransportTransactionMode transportTransactionMode)
        {
            var transport = endpointConfig.UseTransport <SqlServerTransport>();

            ConfigureConnection(transport, transportSettings);
            endpointConfig.Settings.Set("SqlServer.DisableDelayedDelivery", true);

            var sendOnlyEndpoint = transport.GetSettings().GetOrDefault <bool>("Endpoint.SendOnly");

            if (!sendOnlyEndpoint)
            {
                transport.NativeDelayedDelivery();
            }

            transport.Transactions(transportTransactionMode);
        }
Ejemplo n.º 17
0
        Resubscriber(string inputQueueName, TimeSpan delay, Action <TransportExtensions <T> > configureTransport)
        {
            this.inputQueueName = inputQueueName;
            config = RawEndpointConfiguration.Create(inputQueueName + ".Resubscriber",
                                                     async(context, dispatcher) =>
            {
                context.Headers.TryGetValue(Headers.SubscriptionMessageType, out var messageTypeString);
                if (!context.Headers.TryGetValue(Headers.SubscriberTransportAddress, out var subscriberAddress))
                {
                    subscriberAddress = context.Headers[Headers.ReplyToAddress];
                }

                var key = Tuple.Create(subscriberAddress, messageTypeString);
                var resubscriptionId        = context.Headers[ResubscriptionIdHeader];
                var resubscriptionTimestamp = DateTime.Parse(context.Headers[ResubscriptionTimestampHeader]);
                if (idMap.ContainsKey(key))
                {
                    var valuePair = idMap[key];
                    if (valuePair.Item1 != resubscriptionId && resubscriptionTimestamp < valuePair.Item2)
                    {
                        //If we already processed a newer subscribe/unsubscribe message for this -> ignore
                        return;
                    }
                    //We've seen that same message before. Let's pause the resubscription for some time
                    await Task.Delay(delay);
                }

                //Send it to the bridge to re-subscribe
                var outgoingMessage = new OutgoingMessage(context.MessageId, context.Headers, context.Body);
                var operation       = new TransportOperation(outgoingMessage, new UnicastAddressTag(inputQueueName));

                await dispatcher.Dispatch(new TransportOperations(operation), context.TransportTransaction, context.Extensions).ConfigureAwait(false);
                logger.Debug("Moved subscription message back to the queue.");
                idMap[key] = Tuple.Create(resubscriptionId, resubscriptionTimestamp);
            }, "poison");
            config.AutoCreateQueue();
            config.LimitMessageProcessingConcurrencyTo(1);
            var transport = config.UseTransport <T>();

            configureTransport(transport);
        }
        static void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings)
        {
            var transport = endpointConfig.UseTransport <RabbitMQTransport>();

            ConfigureTransport(transport, transportSettings);
        }
        public override void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings)
        {
            var transport = endpointConfig.UseTransport <SqsTransport>();

            ConfigureTransport(transport, transportSettings);
        }
Ejemplo n.º 20
0
        public override void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings)
        {
            var transport = endpointConfig.UseTransport <AzureServiceBusTransport>();

            transport.ConfigureTransport(transportSettings);
        }
Ejemplo n.º 21
0
        static void CustomizeRawEndpoint(RawEndpointConfiguration endpointConfig, TransportSettings transportSettings, TransportTransactionMode transportTransactionMode)
        {
            var transport = endpointConfig.UseTransport <MsmqTransport>();

            transport.Transactions(transportTransactionMode);
        }