示例#1
0
        public IClientContextSupervisor CreateClientContextSupervisor()
        {
            var clientContextSupervisor = new ClientContextSupervisor(this);

            AddConsumeAgent(clientContextSupervisor);

            return(clientContextSupervisor);
        }
示例#2
0
        Task <ISendTransport> CreateTransport <T>(IClientContextSupervisor clientContextSupervisor, IPipe <ClientContext> configureTopology, string entityName,
                                                  Func <SqsSendTransportContext, T> factory)
            where T : Supervisor, ISendTransport
        {
            var supervisor = new ClientContextSupervisor(clientContextSupervisor);

            var transportContext = new SendTransportContext(_hostConfiguration, supervisor, configureTopology, entityName);

            var transport = factory(transportContext);

            clientContextSupervisor.AddSendAgent(transport);

            return(Task.FromResult <ISendTransport>(transport));
        }
        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));
            }
        }
        public Task <ISendTransport> GetPublishTransport <T>(Uri publishAddress)
            where T : class
        {
            LogContext.SetCurrentIfNull(_hostConfiguration.LogContext);

            IAmazonSqsMessagePublishTopology <T> publishTopology = _topologyConfiguration.Publish.GetMessageTopology <T>();

            var settings = publishTopology.GetPublishSettings(_hostConfiguration.HostAddress);

            var clientContextSupervisor = new ClientContextSupervisor(this);

            IPipe <ClientContext> configureTopologyPipe = new ConfigureTopologyFilter <PublishSettings>(settings, publishTopology.GetBrokerTopology()).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));
        }
示例#5
0
 public Task Send(IPipe <ClientContext> pipe, CancellationToken cancellationToken)
 {
     return(_hostConfiguration.Retry(() => ClientContextSupervisor.Send(pipe, cancellationToken), ClientContextSupervisor, cancellationToken));
 }