/// <summary> /// Register for publishing messages to SNS /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public IHaveFulfilledPublishRequirements WithSnsMessagePublisher <T>() where T : Message { Log.Info("Adding SNS publisher"); _subscriptionConfig.Topic = GetMessageTypeName <T>(); var namingStrategy = GetNamingStrategy(); Bus.SerialisationRegister.AddSerialiser <T>(_serialisationFactory.GetSerialiser <T>()); var topicName = namingStrategy.GetTopicName(_subscriptionConfig.BaseTopicName, GetMessageTypeName <T>()); foreach (var region in Bus.Config.Regions) { var eventPublisher = new SnsTopicByName( topicName, _awsClientFactoryProxy.GetAwsClientFactory().GetSnsClient(RegionEndpoint.GetBySystemName(region)), Bus.SerialisationRegister); if (!eventPublisher.Exists()) { eventPublisher.Create(); } Bus.AddMessagePublisher <T>(eventPublisher, region); } Log.Info(string.Format("Created SNS topic publisher - Topic: {0}", _subscriptionConfig.Topic)); return(this); }
private IHaveFulfilledPublishRequirements AddSnsMessagePublisher <T>(Action <SnsWriteConfiguration> configBuilder) where T : Message { _log.LogInformation("Adding SNS publisher"); var snsWriteConfig = new SnsWriteConfiguration(); configBuilder?.Invoke(snsWriteConfig); _subscriptionConfig.Topic = GetMessageTypeName <T>(); var namingStrategy = GetNamingStrategy(); Bus.SerialisationRegister.AddSerialiser <T>(_serialisationFactory.GetSerialiser <T>()); var topicName = namingStrategy.GetTopicName(_subscriptionConfig.BaseTopicName, GetMessageTypeName <T>()); foreach (var region in Bus.Config.Regions) { // TODO pass region down into topic creation for when we have foreign topics so we can generate the arn var eventPublisher = new SnsTopicByName( topicName, _awsClientFactoryProxy.GetAwsClientFactory().GetSnsClient(RegionEndpoint.GetBySystemName(region)), Bus.SerialisationRegister, _loggerFactory, snsWriteConfig); eventPublisher.Create(); eventPublisher.EnsurePolicyIsUpdated(Bus.Config.AdditionalSubscriberAccounts); Bus.AddMessagePublisher <T>(eventPublisher, region); } _log.LogInformation($"Created SNS topic publisher - Topic: {_subscriptionConfig.Topic}"); return(this); }
/// <summary> /// Register for publishing messages to SNS /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public IHaveFulfilledPublishRequirements WithSnsMessagePublisher <T>() where T : Message { Log.Info("Adding SNS publisher"); _subscriptionConfig.Topic = typeof(T).ToTopicName(); var publishEndpointProvider = CreatePublisherEndpointProvider(_subscriptionConfig); Bus.SerialisationRegister.AddSerialiser <T>(_serialisationFactory.GetSerialiser <T>()); foreach (var region in Bus.Config.Regions) { var eventPublisher = new SnsTopicByName( publishEndpointProvider.GetLocationName(), AWSClientFactory.CreateAmazonSimpleNotificationServiceClient(RegionEndpoint.GetBySystemName(region)), Bus.SerialisationRegister); if (!eventPublisher.Exists()) { eventPublisher.Create(); } Bus.AddMessagePublisher <T>(eventPublisher, region); } Log.Info(string.Format("Created SNS topic publisher - Topic: {0}", _subscriptionConfig.Topic)); return(this); }
/// <summary> /// Register for publishing messages to SNS /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public IHaveFulfilledPublishRequirements WithSnsMessagePublisher <T>() where T : Message { Log.Info("Adding SNS publisher"); _subscriptionConfig.Topic = GetMessageTypeName <T>(); var namingStrategy = GetNamingStrategy(); Bus.SerialisationRegister.AddSerialiser <T>(_serialisationFactory.GetSerialiser <T>()); var topicName = namingStrategy.GetTopicName(_subscriptionConfig.BaseTopicName, GetMessageTypeName <T>()); foreach (var region in Bus.Config.Regions) { // TODO pass region down into topic creation for when we have foreign topics so we can generate the arn var eventPublisher = new SnsTopicByName( topicName, _awsClientFactoryProxy.GetAwsClientFactory().GetSnsClient(RegionEndpoint.GetBySystemName(region)), Bus.SerialisationRegister); if (!eventPublisher.Exists()) { eventPublisher.Create(); } eventPublisher.EnsurePolicyIsUpdated(Bus.Config.AdditionalSubscriberAccounts); Bus.AddMessagePublisher <T>(eventPublisher, region); } Log.Info("Created SNS topic publisher - Topic: {0}", _subscriptionConfig.Topic); return(this); }