Exemple #1
0
        ISendTransport CreateSendTransport(IModelContextSupervisor modelContextSupervisor, IPipe <ModelContext> pipe, string exchangeName)
        {
            var sendTransportContext = new HostRabbitMqSendTransportContext(modelContextSupervisor, pipe, exchangeName, SendLogContext);

            var transport = new RabbitMqSendTransport(sendTransportContext);

            Add(transport);

            return(transport);
        }
Exemple #2
0
        public Task <ISendTransport> GetPublishTransport <T>(Uri publishAddress)
            where T : class
        {
            IRabbitMqMessagePublishTopology <T> publishTopology = _publishTopology.GetMessageTopology <T>();

            var sendSettings = publishTopology.GetSendSettings();

            var brokerTopology = publishTopology.GetBrokerTopology(_publishTopology.BrokerTopologyOptions);

            IAgent <ModelContext> modelSource = GetModelSource();

            var sendTransport = new RabbitMqSendTransport(modelSource, new ConfigureTopologyFilter <SendSettings>(sendSettings, brokerTopology), sendSettings.ExchangeName);

            _host.Add(sendTransport);

            return(Task.FromResult <ISendTransport>(sendTransport));
        }
        Task <CachedSendEndpoint <TypeKey> > CreateSendEndpoint <T>(TypeKey typeKey, IRabbitMqMessagePublishTopology <T> publishTopology)
            where T : class
        {
            var sendSettings = publishTopology.GetSendSettings();

            var builder = new PublishEndpointBrokerTopologyBuilder(_host.Topology.PublishTopology.BrokerTopologyOptions);

            publishTopology.Apply(builder);

            var topology = builder.BuildTopologyLayout();

            var modelCache = new RabbitMqModelCache(_host);

            var sendTransport = new RabbitMqSendTransport(modelCache, new ConfigureTopologyFilter <SendSettings>(sendSettings, topology),
                                                          sendSettings.ExchangeName);

            sendTransport.ConnectSendObserver(_sendObservable);

            var sendEndpoint = new SendEndpoint(sendTransport, _serializer, typeKey.Address, _sourceAddress, SendPipe.Empty);

            return(Task.FromResult(new CachedSendEndpoint <TypeKey>(typeKey, sendEndpoint)));
        }
Exemple #4
0
        Task <ISendEndpoint> CreateSendEndpoint(Type messageType)
        {
            if (!TypeMetadataCache.IsValidMessageType(messageType))
            {
                throw new MessageException(messageType, "Anonymous types are not valid message types");
            }

            var sendSettings = _host.Settings.GetSendSettings(messageType);

            ExchangeBindingSettings[] bindings = TypeMetadataCache.GetMessageTypes(messageType)
                                                 .SelectMany(type => type.GetExchangeBindings(_host.Settings.MessageNameFormatter))
                                                 .Where(binding => !sendSettings.ExchangeName.Equals(binding.Exchange.ExchangeName))
                                                 .ToArray();

            var destinationAddress = sendSettings.GetSendAddress(_host.Settings.HostAddress);

            var modelCache = new RabbitMqModelCache(_host);

            var sendTransport = new RabbitMqSendTransport(modelCache, sendSettings, bindings);

            return(Task.FromResult <ISendEndpoint>(new SendEndpoint(sendTransport, _serializer, destinationAddress, _sourceAddress, SendPipe.Empty)));
        }
        ISendTransport GetSendTransport(Uri address)
        {
            if (!_busConfiguration.TryGetHost(address, out var hostConfiguration))
            {
                throw new EndpointNotFoundException($"The host was not found for the specified address: {address}");
            }

            var host = hostConfiguration.Host;

            var settings = host.Topology.SendTopology.GetSendSettings(address);

            var brokerTopology = settings.GetBrokerTopology();

            IAgent <ModelContext> modelSource = GetModelSource(host);

            var configureTopologyFilter = new ConfigureTopologyFilter <SendSettings>(settings, brokerTopology);

            var transport = new RabbitMqSendTransport(modelSource, configureTopologyFilter, settings.ExchangeName);

            host.Add(transport);

            return(transport);
        }