Beispiel #1
0
        private static void SetupDependencies(
            out IEmailQueueReceiver <AzureEmailQueueMessage> receiver,
            out IEmailQueueBlobStore blobStore,
            out EmailServiceContext context,
            out IMemoryCache cache,
            out IEmailLogWriter logWriter)
        {
            var storageOptions = Options.Create(new AzureStorageOptions
            {
                ConnectionString = Configuration.GetConnectionString("Storage")
            });

            receiver  = new StorageEmailQueue(storageOptions, LoggerFactory);
            blobStore = new AzureEmailQueueBlobStore(storageOptions, LoggerFactory);
            logWriter = new StorageEmailLog(storageOptions, LoggerFactory);

            var cacheOptions = Options.Create(new MemoryCacheOptions
            {
                CompactOnMemoryPressure = true,
                ExpirationScanFrequency = TimeSpan.FromMinutes(1)
            });

            cache = new MemoryCache(cacheOptions);

            var builder = new DbContextOptionsBuilder <EmailServiceContext>();

            builder.UseSqlServer(Configuration.GetConnectionString("SqlServer"));
            builder.UseMemoryCache(cache);
            context = new EmailServiceContext(builder.Options);
        }
 public MessagesController(
     IEmailQueueSender sender,
     IEmailQueueBlobStore blobStore,
     IEmailLogReader logReader,
     IEmailLogWriter logWriter,
     ILoggerFactory loggerFactory)
 {
     _sender    = sender;
     _blobStore = blobStore;
     _logReader = logReader;
     _logWriter = logWriter;
     _logger    = loggerFactory.CreateLogger <MessagesController>();
 }
Beispiel #3
0
 public QueueProcessor(
     EmailServiceContext db,
     IEmailQueueReceiver <TMessage> receiver,
     IEmailQueueBlobStore blobStore,
     IEmailTransportFactory transportFactory,
     IEmailLogWriter logWriter,
     ILoggerFactory loggerFactory)
 {
     _db               = db;
     _receiver         = receiver;
     _blobStore        = blobStore;
     _transportFactory = transportFactory;
     _logWriter        = logWriter;
     _logger           = loggerFactory.CreateLogger <QueueProcessor <TMessage> >();
 }