/// <summary>
 /// Initializes a new <see cref="SQLMessageQueueingService"/> with the specified connection
 /// string settings and dialect
 /// </summary>
 /// <param name="options">Options influencing the behavior of this service</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="options"/>
 /// is <c>null</c></exception>
 /// <remarks>
 /// <para>If a SQL dialect is not specified, then one will be selected based on the
 /// supplied connection string settings</para>
 /// <para>If a security token service is not specified then a default implementation
 /// based on unsigned JWTs will be used.</para>
 /// </remarks>
 /// <seealso cref="Platibus.Config.Extensibility.IMessageQueueingCommandBuildersProvider"/>
 public SQLMessageQueueingService(SQLMessageQueueingOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     DiagnosticService         = options.DiagnosticService ?? Diagnostics.DiagnosticService.DefaultInstance;
     ConnectionProvider        = options.ConnectionProvider;
     CommandBuilders           = options.CommandBuilders;
     _securityTokenService     = options.SecurityTokenService ?? new JwtSecurityTokenService();
     _messageEncryptionService = options.MessageEncryptionService;
 }
Beispiel #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);
        }