예제 #1
0
        public void Initialize()
        {
            // Configuration Parameters
            var eventDatabaseConnectionString = "Data Source=localhost;Initial Catalog=eventway-sample-db;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            var projectionMetadataDatabaseConnectionString = eventDatabaseConnectionString;

            var cosmosDbEndpoint     = "https://localhost:8081"; // This is the default endpoint for local emulator-instances of the Cosmos DB
            var cosmosDbAuthKey      = "<REPLACE WITH YOUR COSMOS DB AUTH KEY>";
            var cosmosDbDatabaseId   = "eventway-sample-db";
            var cosmosDbCollectionId = "projections";
            var offerThroughput      = 10000;
            var noOfPartitions       = 1000;

            // Event Repository
            var eventRepository = new SqlServerEventRepository(eventDatabaseConnectionString);

            // Projection Metadata Repository
            var projectionMetadataRepository = new SqlServerProjectionMetadataRepository(projectionMetadataDatabaseConnectionString);

            // Query Model Repository
            var queryModelRepository = new DocumentDbQueryModelRepository(cosmosDbDatabaseId, cosmosDbCollectionId,
                                                                          offerThroughput, noOfPartitions, cosmosDbEndpoint, cosmosDbAuthKey);

            queryModelRepository.Initialize();

            // Event Listener
            var eventListener = new BasicEventListener();

            // Aggregate services
            var aggregateFactory    = new DefaultAggregateFactory();
            var aggregateRepository = new AggregateRepository(eventRepository, aggregateFactory);
            var aggregateStore      = new AggregateStore(aggregateRepository, eventListener);

            // PROJECTIONS
            UserProjection = new UserProjection(
                eventRepository,
                eventListener,
                queryModelRepository,
                projectionMetadataRepository);

            // APPLICATION SERVICES
            UserApplicationService = new UserApplicationService(
                aggregateStore,
                queryModelRepository);

            // Start listening for events
            UserProjection.Listen();
        }
예제 #2
0
        public void Initialize()
        {
            // Configuration Parameters
            var eventDatabaseConnectionString = "Data Source=localhost;Initial Catalog=eventway;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
            var projectionMetadataDatabaseConnectionString = eventDatabaseConnectionString;

            var cosmosDbEndpoint     = "https://localhost:8081"; // This is the default endpoint for local emulator-instances of the Cosmos DB
            var cosmosDbAuthKey      = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==";
            var cosmosDbDatabaseId   = "eventway";
            var cosmosDbCollectionId = "projections";
            var offerThroughput      = 10000;
            var noOfPartitions       = 1000;

            // Event Repository
            var eventRepository = new SqlServerEventRepository(eventDatabaseConnectionString);

            // Projection Metadata Repository
            var projectionMetadataRepository = new SqlServerProjectionMetadataRepository(projectionMetadataDatabaseConnectionString);

            // Query Model Repository
            var queryModelRepository = new CosmosDbQueryModelRepository(cosmosDbDatabaseId, cosmosDbCollectionId,
                                                                        offerThroughput, noOfPartitions, cosmosDbEndpoint, cosmosDbAuthKey);

            queryModelRepository.Initialize();

            // Event Listener
            var eventListener = new BasicEventListener();

            // Aggregate services
            var aggregateFactory    = new DefaultAggregateFactory();
            var aggregateRepository = new AggregateRepository(eventRepository, aggregateFactory);
            var aggregateStore      = new AggregateStore(aggregateRepository, eventListener);

            // PROJECTIONS
            UserProjection = new UserProjection(
                eventRepository,
                eventListener,
                queryModelRepository,
                projectionMetadataRepository);

            // APPLICATION SERVICES
            UserApplicationService = new UserApplicationService(
                aggregateStore,
                queryModelRepository);

            // Start listening for events
            UserProjection.Listen();
        }