コード例 #1
0
        Task <ISendTransport> ISendTransportProvider.GetSendTransport(Uri address)
        {
            var endpointAddress = new AmazonSqsEndpointAddress(_hostConfiguration.HostAddress, address);

            LogContext.SetCurrentIfNull(_hostConfiguration.LogContext);

            TransportLogMessages.CreateSendTransport(endpointAddress);

            if (endpointAddress.Type == AmazonSqsEndpointAddress.AddressType.Queue)
            {
                var settings = _topologyConfiguration.Send.GetSendSettings(endpointAddress);

                var clientContextSupervisor = new ClientContextSupervisor(this);

                IPipe <ClientContext> configureTopologyPipe = new ConfigureTopologyFilter <SendSettings>(settings, settings.GetBrokerTopology()).ToPipe();

                var transportContext = new SendTransportContext(clientContextSupervisor, configureTopologyPipe, settings.EntityName,
                                                                _hostConfiguration.SendLogContext, _hostConfiguration.Settings.AllowTransportHeader);

                var transport = new QueueSendTransport(transportContext);
                Add(transport);

                return(Task.FromResult <ISendTransport>(transport));
            }
            else
            {
                var settings = new TopicPublishSettings(endpointAddress);

                var clientContextSupervisor = new ClientContextSupervisor(this);

                var builder     = new PublishEndpointBrokerTopologyBuilder();
                var topicHandle = builder.CreateTopic(settings.EntityName, settings.Durable, settings.AutoDelete, settings.TopicAttributes, settings
                                                      .TopicSubscriptionAttributes, settings.Tags);

                builder.Topic ??= topicHandle;

                IPipe <ClientContext> configureTopologyPipe = new ConfigureTopologyFilter <PublishSettings>(settings, builder.BuildBrokerTopology()).ToPipe();

                var transportContext = new SendTransportContext(clientContextSupervisor, configureTopologyPipe, settings.EntityName,
                                                                _hostConfiguration.SendLogContext, _hostConfiguration.Settings.AllowTransportHeader);

                var transport = new TopicSendTransport(transportContext);
                Add(transport);

                return(Task.FromResult <ISendTransport>(transport));
            }
        }
コード例 #2
0
ファイル: AmazonSqsHost.cs プロジェクト: tuita520/MassTransit
        public Task <ISendTransport> CreateSendTransport(AmazonSqsEndpointAddress address)
        {
            var settings = _hostTopology.SendTopology.GetSendSettings(address);

            var clientContextSupervisor = new AmazonSqsClientContextSupervisor(ConnectionContextSupervisor);

            var configureTopologyPipe = new ConfigureTopologyFilter <SendSettings>(settings, settings.GetBrokerTopology()).ToPipe();

            var transportContext = new HostSqsSendTransportContext(clientContextSupervisor, configureTopologyPipe, settings.EntityName, SendLogContext,
                                                                   _hostConfiguration.Settings.AllowTransportHeader);

            var transport = new QueueSendTransport(transportContext);

            Add(transport);

            return(Task.FromResult <ISendTransport>(transport));
        }
コード例 #3
0
        public Task <ISendTransport> CreateSendTransport(AmazonSqsEndpointAddress address)
        {
            TransportLogMessages.CreateSendTransport(address);

            if (address.Type == AmazonSqsEndpointAddress.AddressType.Queue)
            {
                var settings = _hostTopology.SendTopology.GetSendSettings(address);

                var clientContextSupervisor = new AmazonSqsClientContextSupervisor(ConnectionContextSupervisor);

                var configureTopologyPipe = new ConfigureTopologyFilter <SendSettings>(settings, settings.GetBrokerTopology()).ToPipe();

                var transportContext = new HostSqsSendTransportContext(clientContextSupervisor, configureTopologyPipe, settings.EntityName, SendLogContext,
                                                                       _hostConfiguration.Settings.AllowTransportHeader);

                var transport = new QueueSendTransport(transportContext);
                Add(transport);

                return(Task.FromResult <ISendTransport>(transport));
            }
            else
            {
                var settings = new TopicPublishSettings(address);

                var clientContextSupervisor = new AmazonSqsClientContextSupervisor(ConnectionContextSupervisor);

                var builder     = new PublishEndpointBrokerTopologyBuilder();
                var topicHandle = builder.CreateTopic(settings.EntityName, settings.Durable, settings.AutoDelete, settings.TopicAttributes, settings
                                                      .TopicSubscriptionAttributes, settings.Tags);

                builder.Topic ??= topicHandle;

                var configureTopologyPipe = new ConfigureTopologyFilter <PublishSettings>(settings, builder.BuildBrokerTopology()).ToPipe();

                var transportContext = new HostSqsSendTransportContext(clientContextSupervisor, configureTopologyPipe, settings.EntityName, SendLogContext,
                                                                       _hostConfiguration.Settings.AllowTransportHeader);

                var transport = new TopicSendTransport(transportContext);
                Add(transport);

                return(Task.FromResult <ISendTransport>(transport));
            }
        }