Task <ISendTransport> CreateSendTransport(IModelContextSupervisor modelContextSupervisor, IPipe <ModelContext> pipe, string exchangeName)
        {
            var supervisor = new ModelContextSupervisor(modelContextSupervisor);

            var sendTransportContext = new SendTransportContext(_hostConfiguration, supervisor, pipe, exchangeName);

            var transport = new RabbitMqSendTransport(sendTransportContext);

            modelContextSupervisor.AddSendAgent(transport);

            return(Task.FromResult <ISendTransport>(transport));
        }
        public Task <ISendTransport> CreatePublishTransport <T>(IModelContextSupervisor modelContextSupervisor)
            where T : class
        {
            LogContext.SetCurrentIfNull(_hostConfiguration.LogContext);

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

            var sendSettings = publishTopology.GetSendSettings(_hostConfiguration.HostAddress);

            var brokerTopology = publishTopology.GetBrokerTopology();

            var supervisor = new ModelContextSupervisor(modelContextSupervisor);

            IPipe <ModelContext> configureTopology = new ConfigureTopologyFilter <SendSettings>(sendSettings, brokerTopology).ToPipe();

            return(CreateSendTransport(supervisor, configureTopology, publishTopology.Exchange.ExchangeName));
        }
        public Task <ISendTransport> CreateSendTransport(IModelContextSupervisor modelContextSupervisor, Uri address)
        {
            LogContext.SetCurrentIfNull(_hostConfiguration.LogContext);

            var endpointAddress = new RabbitMqEndpointAddress(_hostConfiguration.HostAddress, address);

            TransportLogMessages.CreateSendTransport(endpointAddress);

            var settings = _topologyConfiguration.Send.GetSendSettings(endpointAddress);

            var brokerTopology = settings.GetBrokerTopology();

            IPipe <ModelContext> configureTopology = new ConfigureTopologyFilter <SendSettings>(settings, brokerTopology).ToPipe();

            var supervisor = new ModelContextSupervisor(modelContextSupervisor);

            return(CreateSendTransport(supervisor, configureTopology, settings.ExchangeName));
        }
Пример #4
0
        Task <ISendTransport> CreateSendTransport(IModelContextSupervisor modelContextSupervisor, IPipe <ModelContext> pipe, string exchangeName,
                                                  RabbitMqEndpointAddress endpointAddress)
        {
            var supervisor = new ModelContextSupervisor(modelContextSupervisor);

            var delayedExchangeAddress = endpointAddress.GetDelayAddress();

            var delaySettings = new RabbitMqDelaySettings(delayedExchangeAddress);

            delaySettings.BindToExchange(exchangeName);

            IPipe <ModelContext> delayPipe = new ConfigureTopologyFilter <DelaySettings>(delaySettings, delaySettings.GetBrokerTopology()).ToPipe();

            var sendTransportContext = new SendTransportContext(_hostConfiguration, supervisor, pipe, exchangeName, delayPipe, delaySettings.ExchangeName);

            var transport = new RabbitMqSendTransport(sendTransportContext);

            modelContextSupervisor.AddSendAgent(transport);

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