/// <summary>
        /// For sending messages.
        /// </summary>
        public static async Task <IServiceCollection> AddServiceBusQueueBrokerAsync <TMessageType>(
            this IServiceCollection collectionBuilder,
            IConfiguration configuration)
            where TMessageType : class, IMessageContract
        {
            var attribute = MessageTopicAttribute.GetRequiredForType <TMessageType>();

            var infrastructureUpdater = new InfrastructureUpdater(configuration);
            await infrastructureUpdater.CreateQueueAsync(attribute.Topic);

            collectionBuilder.TryAddMessageSerializer <TMessageType>();
            collectionBuilder.AddSingleton <IMessageProducer <TMessageType> >(svc => new MessageBroker <TMessageType>(attribute.Topic, svc, ChannelType.PointToPoint));
            return(collectionBuilder);
        }
        public static async Task <Microsoft.AspNetCore.Builder.IApplicationBuilder> CreateOrUpdateTopicSubscriptionAsync <TMessageType>(
            this Microsoft.AspNetCore.Builder.IApplicationBuilder app,
            string serviceName)
            where TMessageType : class, IMessageContract
        {
            var configuration = app.ApplicationServices.GetService <IConfiguration>();

            if (configuration.IsCodeFirstServiceBus())
            {
                var attribute = MessageTopicAttribute.GetForType <TMessageType>();
                if (attribute == null)
                {
                    throw new InternalErrorException($"Missing topic, use {nameof(MessageTopicAttribute)}");
                }
                var connectionString = configuration.GetServiceBusConnectionString();
                var channelName      = configuration.GetServiceBusChannelName(ChannelType.PublishSubscribe, attribute.Topic);
                var messageHandler   = app.ApplicationServices.GetService <IMessageHandler <TMessageType> >();

                var infrastructureUpdater = new InfrastructureUpdater(configuration);
                await infrastructureUpdater.CreateOrUpdateSubscriptionAsync <TMessageType>(connectionString, channelName, serviceName, attribute.Topic, messageHandler);
            }

            return(app);
        }