Beispiel #1
0
        private async Task <Container> GetDestinationContainer(ConsumerRouterSettings consumerRouterSettings, string topic)
        {
            if (consumerRouterSettings.IsIndividualTopicsRoutingEnabled)
            {
                if (consumerRouterSettings.WhiteListedTopies.Contains(topic))
                {
                    // Route these to specific container
                    // Make sure topic container exists
                    if (!CosmosClientPool.IsTopicExists(topic))
                    {
                        Database database = CosmosClientPool.GetCosmosClient(this.cosmosDBSettings.Consumer).GetDatabase(this.cosmosDBSettings.Consumer.Database);
                        // Create a new container in the same database.
                        Container container = await CosmosExtension.SetupCollectionAsync(database, topic, this.cosmosDBSettings.Consumer.PartitionKeyPath, this.cosmosDBSettings.Consumer.CreateIfContainerNotExists, this.cosmosDBSettings.Consumer.DeleteIfContainerExists);

                        CosmosClientPool.AddTopic(topic);
                        return(container);
                    }

                    return(CosmosClientPool.GetCosmosClient(this.cosmosDBSettings.Consumer).GetContainer(this.cosmosDBSettings.Consumer.Database, topic));
                }
            }

            // Default container
            return(CosmosClientPool.GetCosmosClient(this.cosmosDBSettings.Consumer).GetContainer(this.cosmosDBSettings.Consumer.Database, this.cosmosDBSettings.Consumer.Container));
        }
        private async Task InitClientsAsync()
        {
            CosmosClientPool.CreateClient(this.cosmosDBSettings.Producer);
            CosmosClientPool.CreateClient(this.cosmosDBSettings.Lease);

            //await CosmosExtension.SetupCosmosDBEntitiesAsync(this.cosmosDBSettings.Producer);

            await CosmosExtension.SetupCosmosDBEntitiesAsync(this.cosmosDBSettings.Lease);

            Microsoft.Azure.Cosmos.Container leaseContainer  = CosmosClientPool.GetCosmosClient(this.cosmosDBSettings.Lease).GetContainer(this.cosmosDBSettings.Lease.Database, this.cosmosDBSettings.Lease.Container);
            Microsoft.Azure.Cosmos.Container sourceContainer = CosmosClientPool.GetCosmosClient(this.cosmosDBSettings.Producer).GetContainer(this.cosmosDBSettings.Producer.Database, this.cosmosDBSettings.Producer.Container);
            this.changeFeedProcessor = sourceContainer
                                       .GetChangeFeedProcessorBuilder <EventDataModel>("changeFeedBeginning", this.changesHandler)
                                       .WithInstanceName("EventprocessingConsole")
                                       .WithLeaseContainer(leaseContainer)
                                       .WithStartTime(DateTime.MinValue.ToUniversalTime())
                                       .Build();
            await this.changeFeedProcessor.StartAsync();
        }
Beispiel #3
0
        public async Task InitClientsAsync()
        {
            CosmosClientPool.CreateClient(this.cosmosDBSettings.Consumer);

            await CosmosExtension.SetupCosmosDBEntitiesAsync(this.cosmosDBSettings.Consumer);
        }
        public static async Task SetupCosmosDBEntitiesAsync(CosmosDBAccount cosmosDBAccount)
        {
            Database database = await CosmosExtension.SetupDatabaseAsync(cosmosDBAccount.Database, cosmosDBAccount.CreateIfContainerNotExists, cosmosDBAccount.DeleteIfDatabaseExists, CosmosClientPool.GetCosmosClient(cosmosDBAccount));

            await CosmosExtension.SetupCollectionAsync(database, cosmosDBAccount.Container, cosmosDBAccount.PartitionKeyPath, cosmosDBAccount.CreateIfContainerNotExists, cosmosDBAccount.DeleteIfContainerExists);
        }