Exemplo n.º 1
0
        private IExchange DeclareVersionedExchanges(IAdvancedBus advancedBus, IConventions conventions, MessageVersionStack messageVersions, string exchangeType)
        {
            IExchange destinationExchange = null;

            while (!messageVersions.IsEmpty())
            {
                var messageType    = messageVersions.Pop();
                var exchangeName   = conventions.ExchangeNamingConvention(messageType);
                var sourceExchange = DeclareExchange(advancedBus, exchangeName, exchangeType);
                if (destinationExchange != null)
                {
                    advancedBus.Bind(sourceExchange, destinationExchange, "#");
                }
                destinationExchange = sourceExchange;
            }
            return(destinationExchange);
        }
Exemplo n.º 2
0
        private async Task <IExchange> DeclareVersionedExchangesAsync(IAdvancedBus advancedBus, IConventions conventions, MessageVersionStack messageVersions, string exchangeType)
        {
            IExchange destinationExchange = null;

            while (!messageVersions.IsEmpty())
            {
                var messageType    = messageVersions.Pop();
                var exchangeName   = conventions.ExchangeNamingConvention(messageType);
                var sourceExchange = await DeclareExchangeAsync(advancedBus, exchangeName, exchangeType).ConfigureAwait(false);

                if (destinationExchange != null)
                {
                    await advancedBus.BindAsync(sourceExchange, destinationExchange, "#").ConfigureAwait(false);
                }
                destinationExchange = sourceExchange;
            }
            return(destinationExchange);
        }
Exemplo n.º 3
0
        private Task <IExchange> DeclareVersionedExchanges(IAdvancedBus advancedBus, IConventions conventions, MessageVersionStack messageVersions, string exchangeType)
        {
            var destinationExchangeTask = TaskHelpers.FromResult <IExchange>(null);

            while (!messageVersions.IsEmpty())
            {
                var messageType  = messageVersions.Pop();
                var exchangeName = conventions.ExchangeNamingConvention(messageType);
                destinationExchangeTask = destinationExchangeTask.Then(destinationExchange => DeclareExchangeAsync(advancedBus, exchangeName, exchangeType).Then(sourceExchange =>
                {
                    if (destinationExchange != null)
                    {
                        return(advancedBus.BindAsync(sourceExchange, destinationExchange, "#").Then(() => sourceExchange));
                    }
                    return(TaskHelpers.FromResult(sourceExchange));
                }));
            }
            return(destinationExchangeTask);
        }
        private IExchange DeclareVersionedExchanges(IAdvancedBus advancedBus, IConventions conventions, MessageVersionStack messageVersions, string exchangeType)
        {
            // This works because the message version stack is LIFO from most superseded message type to the actual message type
            IExchange destinationExchange = null;

            while (!messageVersions.IsEmpty())
            {
                var messageType    = messageVersions.Pop();
                var exchangeName   = conventions.ExchangeNamingConvention(messageType);
                var sourceExchange = DeclareExchange(advancedBus, exchangeName, exchangeType);

                if (destinationExchange != null)
                {
                    advancedBus.Bind(sourceExchange, destinationExchange, "#");
                }

                destinationExchange = sourceExchange;
            }
            return(destinationExchange);
        }