public SqsQueueByName EnsureTopicExistsWithQueueSubscribed(string region, IMessageSerialisationRegister serialisationRegister, SqsReadConfiguration queueConfig) { var regionEndpoint = RegionEndpoint.GetBySystemName(region); var queue = EnsureQueueExists(region, queueConfig); var eventTopic = EnsureTopicExists(regionEndpoint, serialisationRegister, queueConfig); EnsureQueueIsSubscribedToTopic(regionEndpoint, eventTopic, queue); var sqsclient = _awsClientFactory.GetAwsClientFactory().GetSqsClient(regionEndpoint); SqsPolicy.Save(eventTopic.Arn, queue.Arn, queue.Url, sqsclient); return(queue); }
public SqsQueueByName EnsureTopicExistsWithQueueSubscribed(string region, IMessageSerialisationRegister serialisationRegister, SqsReadConfiguration queueConfig) { var regionEndpoint = RegionEndpoint.GetBySystemName(region); var queue = EnsureQueueExists(region, queueConfig); if (TopicExistsInAnotherAccount(queueConfig)) { var sqsClient = _awsClientFactory.GetAwsClientFactory().GetSqsClient(regionEndpoint); var snsClient = _awsClientFactory.GetAwsClientFactory().GetSnsClient(regionEndpoint); var arnProvider = new ForeignTopicArnProvider(regionEndpoint, queueConfig.TopicSourceAccount, queueConfig.PublishEndpoint); snsClient.SubscribeQueue(arnProvider.GetArn(), sqsClient, queue.Url); } else { var eventTopic = EnsureTopicExists(regionEndpoint, serialisationRegister, queueConfig); EnsureQueueIsSubscribedToTopic(regionEndpoint, eventTopic, queue); var sqsclient = _awsClientFactory.GetAwsClientFactory().GetSqsClient(regionEndpoint); SqsPolicy.Save(eventTopic.Arn, queue.Arn, queue.Url, sqsclient); } return(queue); }