예제 #1
0
        public static IServiceCollection AddQueueSender <T>(this IServiceCollection services,
                                                            string connectionString, string queueName)
        {
            var conn = new ServiceBusConnectionProvider <T>(connectionString, queueName);

            services.AddScoped(typeof(IProvideServiceBusConnection <T>), (p => conn));
            services.AddScoped(typeof(ISendMessage <T>), typeof(MessageSender <T>));

            return(services);
        }
예제 #2
0
        public static IServiceCollection AddTopicSender <T>(this IServiceCollection services,
                                                            string connectionString, string topicName)
        {
            var conn = new ServiceBusConnectionProvider <T>(connectionString, topicName, null);

            services.AddScoped(typeof(IProvideServiceBusConnection <T>), (p => conn));
            services.AddScoped(typeof(ISendMessage <T>), typeof(TopicSender <T>));

            return(services);
        }
예제 #3
0
        public static IServiceCollection AddSubscriptionHandler <T, TProcessor>(this IServiceCollection services,
                                                                                string connectionString, string topicName, string subscriptionName)
        {
            var conn = new ServiceBusConnectionProvider <T>(connectionString, topicName, subscriptionName);

            services.AddScoped(typeof(IProvideServiceBusConnection <T>), (p => conn));
            services.AddScoped(typeof(IHandleMessage <T>), typeof(MessageHandler <T>));
            services.AddScoped(typeof(IRegisterHandler <T>), typeof(RegisterSubscriptionHandler <T>));
            services.AddScoped(typeof(IProcessMessage <T>), typeof(TProcessor));

            return(services);
        }
예제 #4
0
        public static IServiceCollection AddQueueHandler <T, TProcessor>(this IServiceCollection services,
                                                                         string connectionString, string queueName)
        {
            var conn = new ServiceBusConnectionProvider <T>(connectionString, queueName);

            services.AddSingleton(typeof(IProvideServiceBusConnection <T>), (p) => conn);
            services.AddScoped(typeof(IProcessMessage <T>), typeof(TProcessor));
            services.AddScoped(typeof(IHandleMessage <T>), typeof(MessageHandler <T>));
            services.AddScoped(typeof(IRegisterHandler <T>), typeof(RegisterHandler <T>));

            return(services);
        }