Beispiel #1
0
        /// <inheritdoc />
        public Task <IMessageJournal> CreateMessageJournal(JournalingElement configuration)
        {
            var connectionName = configuration.GetString("connectionName");

            if (string.IsNullOrWhiteSpace(connectionName))
            {
                throw new ConfigurationErrorsException(
                          "Attribute 'connectionName' is required for MongoDB message journal");
            }

            var connectionStringSettings = ConfigurationManager.ConnectionStrings[connectionName];

            if (connectionStringSettings == null)
            {
                throw new ConfigurationErrorsException("Connection string settings \"" + connectionName + "\" not found");
            }

            var databaseName   = configuration.GetString("database");
            var collectionName = configuration.GetString("collection");
            var database       = MongoDBHelper.Connect(connectionStringSettings, databaseName);
            var journalOptions = new MongoDBMessageJournalOptions(database)
            {
                CollectionName = collectionName
            };
            var sqlMessageJournalingService = new MongoDBMessageJournal(journalOptions);

            return(Task.FromResult <IMessageJournal>(sqlMessageJournalingService));
        }
        /// <inheritdoc />
        public Task <IMessageJournal> CreateMessageJournal(JournalingElement configuration)
        {
            var path          = configuration.GetString("path");
            var sqliteBaseDir = GetRootedDirectory(path);
            var sqliteMessageQueueingService = new SQLiteMessageJournal(sqliteBaseDir);

            sqliteMessageQueueingService.Init();
            return(Task.FromResult <IMessageJournal>(sqliteMessageQueueingService));
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a message journal on the supplied
        /// <paramref name="configuration"/>
        /// </summary>
        /// <param name="configuration">The journal configuration</param>
        /// <returns>Returns a task whose result is the initialized message journal</returns>
        public async Task <IMessageJournal> InitMessageJournal(JournalingElement configuration)
        {
            var myConfig = configuration ?? new JournalingElement();

            if (string.IsNullOrWhiteSpace(myConfig.Provider))
            {
                await _diagnosticService.EmitAsync(
                    new DiagnosticEventBuilder(this, DiagnosticEventType.ConfigurationDefault)
                {
                    Detail = "Message journal disabled"
                }.Build());

                return(null);
            }

            var provider       = GetProvider(myConfig.Provider);
            var messageJournal = await provider.CreateMessageJournal(myConfig);

            if (messageJournal == null)
            {
                return(null);
            }

            var messageJournalType = messageJournal.GetType().FullName;

            var categories = new List <MessageJournalCategory>();

            if (myConfig.JournalSentMessages)
            {
                categories.Add(MessageJournalCategory.Sent);
            }
            if (myConfig.JournalReceivedMessages)
            {
                categories.Add(MessageJournalCategory.Received);
            }
            if (myConfig.JournalPublishedMessages)
            {
                categories.Add(MessageJournalCategory.Published);
            }

            var filteredMessageJournalingService = new FilteredMessageJournal(messageJournal, categories);

            messageJournal = filteredMessageJournalingService;

            await _diagnosticService.EmitAsync(
                new DiagnosticEventBuilder(this, DiagnosticEventType.ComponentInitialization)
            {
                Detail = $"Message journal {messageJournalType} initialized"
            }.Build());

            return(new SanitizedMessageJournal(messageJournal));
        }
        public MongoDBServicesProviderMessageJournalTests(MongoDBFixture fixture)
        {
#if NETCOREAPP2_0
            Configuration = new ConfigurationBuilder()
                            .AddInMemoryCollection()
                            .Build();
#endif
            ConnectionStringSettings = fixture.ConnectionStringSettings;
            ConfigureAttribute("connectionName", fixture.ConnectionStringSettings.Name);

            Message = new Message(new MessageHeaders
            {
                MessageId = MessageId.Generate()
            }, "MongoDBServicesProviderMessageJournalTests");
        }
Beispiel #5
0
        /// <inheritdoc />
        public Task <IMessageJournal> CreateMessageJournal(JournalingElement configuration)
        {
            var connectionName = configuration.GetString("connectionName");

            if (string.IsNullOrWhiteSpace(connectionName))
            {
                throw new ConfigurationErrorsException(
                          "Attribute 'connectionName' is required for SQL message journal");
            }

            var connectionStringSettings = ConfigurationManager.ConnectionStrings[connectionName];

            if (connectionStringSettings == null)
            {
                throw new ConfigurationErrorsException($"Connection string settings \"{connectionName}\" not found");
            }
            var sqlMessageJournalingService = new SQLMessageJournal(connectionStringSettings);

            sqlMessageJournalingService.Init();
            return(Task.FromResult <IMessageJournal>(sqlMessageJournalingService));
        }