/// <summary>
        ///     Configures Rebus to use Amazon Simple Queue Service as the message transport
        /// </summary>
        public static void UseAmazonSnsAndSqs(this StandardConfigurer <ITransport> configurer, IAmazonCredentialsFactory amazonCredentialsFactory = null, AmazonSQSConfig amazonSqsConfig = null, AmazonSimpleNotificationServiceConfig amazonSimpleNotificationServiceConfig = null, string workerQueueAddress = "input_queue_address", AmazonSnsAndSqsTransportOptions amazonSnsAndSqsTransportOptions = null, ITopicFormatter topicFormatter = null, SnsAttributeMapperBuilder snsAttributeMapperBuilder = null)
        {
            configurer = configurer ?? throw new ArgumentNullException(nameof(configurer));

            topicFormatter           = topicFormatter ?? new ConventionBasedTopicFormatter();
            amazonCredentialsFactory = amazonCredentialsFactory ?? new FailbackAmazonCredentialsFactory();
            amazonSqsConfig          = amazonSqsConfig ?? new AmazonSQSConfig {
                RegionEndpoint = RegionEndpoint.USWest2
            };
            amazonSnsAndSqsTransportOptions       = amazonSnsAndSqsTransportOptions ?? new AmazonSnsAndSqsTransportOptions();
            snsAttributeMapperBuilder             = snsAttributeMapperBuilder ?? new SnsAttributeMapperBuilder();
            amazonSimpleNotificationServiceConfig = amazonSimpleNotificationServiceConfig ?? new AmazonSimpleNotificationServiceConfig {
                RegionEndpoint = RegionEndpoint.USWest2
            };
            Configure(configurer, amazonCredentialsFactory, amazonSqsConfig, amazonSimpleNotificationServiceConfig, workerQueueAddress, amazonSnsAndSqsTransportOptions, topicFormatter, snsAttributeMapperBuilder);
        }
        private static void Configure(StandardConfigurer <ITransport> configurer, IAmazonCredentialsFactory amazonCredentialsFactory, AmazonSQSConfig amazonSqsConfig, AmazonSimpleNotificationServiceConfig amazonSimpleNotificationServiceConfig, string inputQueueAddress, AmazonSnsAndSqsTransportOptions amazonSnsAndSqsTransportOptions, ITopicFormatter topicFormatter, SnsAttributeMapperBuilder snsAttributeMapperBuilder)
        {
            amazonCredentialsFactory = amazonCredentialsFactory ?? throw new ArgumentNullException(nameof(amazonCredentialsFactory));
            configurer.OtherService <IAmazonCredentialsFactory>().Register(c => amazonCredentialsFactory);

            configurer.OtherService <IAmazonSQSTransportFactory>().Register(c => new AmazonSQSTransportFactory(c.Get <IAmazonInternalSettings>()));
            configurer.OtherService <IAmazonInternalSettings>().Register(c => new AmazonInternalSettings {
                ResolutionContext = c, AmazonSimpleNotificationServiceConfig = amazonSimpleNotificationServiceConfig ?? throw new ArgumentNullException(nameof(amazonSimpleNotificationServiceConfig)), InputQueueAddress = inputQueueAddress ?? throw new ArgumentNullException(nameof(inputQueueAddress)), AmazonSqsConfig = amazonSqsConfig ?? throw new ArgumentNullException(nameof(amazonSqsConfig)), AmazonSnsAndSqsTransportOptions = amazonSnsAndSqsTransportOptions ?? throw new ArgumentNullException(nameof(amazonSnsAndSqsTransportOptions)), MessageSerializer = new AmazonTransportMessageSerializer(), TopicFormatter = topicFormatter ?? throw new ArgumentNullException(nameof(topicFormatter))
            });
Ejemplo n.º 3
0
 /// <summary>
 /// Configures Rebus to use Amazon Simple Queue Service as the message transport
 /// </summary>
 /// <param name="configurer">The configurer.</param>
 /// <param name="amazonCredentialsFactory">The amazon credentials factory.</param>
 /// <param name="amazonSqsConfig">The amazon SQS configuration.</param>
 /// <param name="amazonSimpleNotificationServiceConfig">The amazon simple notification service configuration.</param>
 /// <param name="options">The options.</param>
 /// <param name="topicFormatter">The topic formatter.</param>
 /// <param name="snsAttributeMapperBuilder">The SNS attribute mapper builder.</param>
 public static void UseAmazonSnsAndSqsAsOneWayClient(this StandardConfigurer <ITransport> configurer, IAmazonCredentialsFactory amazonCredentialsFactory = null, AmazonSQSConfig amazonSqsConfig = null, AmazonSimpleNotificationServiceConfig amazonSimpleNotificationServiceConfig = null, AmazonSnsAndSqsTransportOptions options = null, ITopicFormatter topicFormatter = null, SnsAttributeMapperBuilder snsAttributeMapperBuilder = null)
 {
     topicFormatter           = topicFormatter ?? new ConventionBasedTopicFormatter();
     amazonCredentialsFactory = amazonCredentialsFactory ?? new FailbackAmazonCredentialsFactory();
     amazonSqsConfig          = amazonSqsConfig ?? new AmazonSQSConfig {
         RegionEndpoint = RegionEndpoint.USWest2
     };
     options = options ?? new AmazonSnsAndSqsTransportOptions();
     snsAttributeMapperBuilder             = snsAttributeMapperBuilder ?? new SnsAttributeMapperBuilder();
     amazonSimpleNotificationServiceConfig = amazonSimpleNotificationServiceConfig ?? new AmazonSimpleNotificationServiceConfig {
         RegionEndpoint = RegionEndpoint.USWest2
     };
     ConfigureOneWayClient(configurer, amazonCredentialsFactory, amazonSqsConfig, amazonSimpleNotificationServiceConfig, options, topicFormatter, snsAttributeMapperBuilder);
 }