示例#1
0
 /// <summary>
 /// Initializes a new <see cref="SQLMessageJournal"/> with the specified connection
 /// string settings and dialect
 /// </summary>
 /// <param name="connectionStringSettings">The connection string settings to use to connect
 ///     to the SQL database</param>
 /// <param name="commandBuilders">(Optional) A collection of factories capable of
 ///     generating database commands for manipulating queued messages that conform to the SQL
 ///     syntax required by the underlying connection provider (if needed)</param>
 /// <param name="diagnosticService">(Optional) The service through which diagnostic events
 ///     are reported and processed</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="connectionStringSettings"/>
 /// is <c>null</c></exception>
 /// <remarks>
 /// If a SQL dialect is not specified, then one will be selected based on the supplied
 /// connection string settings
 /// </remarks>
 /// <seealso cref="CommandBuildersFactory.InitMessageJournalingCommandBuilders"/>
 /// <seealso cref="IMessageJournalingCommandBuildersProvider"/>
 public SQLMessageJournal(ConnectionStringSettings connectionStringSettings,
                          IMessageJournalingCommandBuilders commandBuilders = null,
                          IDiagnosticService diagnosticService = null)
 {
     if (connectionStringSettings == null)
     {
         throw new ArgumentNullException(nameof(connectionStringSettings));
     }
     DiagnosticService  = diagnosticService ?? Diagnostics.DiagnosticService.DefaultInstance;
     ConnectionProvider = new DefaultConnectionProvider(connectionStringSettings, DiagnosticService);
     CommandBuilders    = commandBuilders ??
                          new CommandBuildersFactory(connectionStringSettings, DiagnosticService)
                          .InitMessageJournalingCommandBuilders();
 }
示例#2
0
        /// <inheritdoc />
        public async Task <IMessageQueueingService> CreateMessageQueueingService(QueueingElement configuration)
        {
            var connectionName = configuration.GetString("connectionName");

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

            var connectionStringSettings = ConfigurationManager.ConnectionStrings[connectionName];

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

            var securityTokenServiceFactory = new SecurityTokenServiceFactory();
            var securityTokenConfig         = configuration.SecurityTokens;
            var securityTokenService        = await securityTokenServiceFactory.InitSecurityTokenService(securityTokenConfig);

            var messageEncryptionServiceFactory = new MessageEncryptionServiceFactory();
            var messageEncryptionConfig         = configuration.Encryption;
            var messageEncryptionService        = await messageEncryptionServiceFactory.InitMessageEncryptionService(messageEncryptionConfig);

            var connectionProvider             = new DefaultConnectionProvider(connectionStringSettings);
            var commandBuildersFactory         = new CommandBuildersFactory(connectionStringSettings);
            var messageQueueingCommandBuilders = commandBuildersFactory.InitMessageQueueingCommandBuilders();
            var messageQueueingOptions         = new SQLMessageQueueingOptions(connectionProvider, messageQueueingCommandBuilders)
            {
                SecurityTokenService     = securityTokenService,
                MessageEncryptionService = messageEncryptionService
            };
            var sqlMessageQueueingService = new SQLMessageQueueingService(messageQueueingOptions);

            sqlMessageQueueingService.Init();
            return(sqlMessageQueueingService);
        }