Exemplo n.º 1
0
        public static async Task Run(string mongoConnectionString, string mongoDBDatabase, string endpointName, string analyzerAddress)
        {
            var mongoDatabase = new MongoClient(mongoConnectionString).GetDatabase(mongoDBDatabase);

            var endpointConfiguration = new EndpointConfiguration(endpointName);

            endpointConfiguration.UseSerialization <JsonSerializer>();
            endpointConfiguration.EnableInstallers();
            endpointConfiguration.UsePersistence <InMemoryPersistence>();
            endpointConfiguration.RegisterComponents(c =>
                                                     c.RegisterSingleton <IRepository <string, IEnumerable <Retweetee> > >(
                                                         new MongoDBListRepository <Retweetee>(mongoDatabase, "most_retweeted__retweetees")));
            endpointConfiguration.ApplyMessageConventions();
            endpointConfiguration.ApplyErrorAndAuditQueueSettings();
            endpointConfiguration.LimitMessageProcessingConcurrencyTo(1);

            var transportExtensions = endpointConfiguration.UseTransport <MsmqTransport>();

            var routing = transportExtensions.Routing();

            routing.RegisterPublisher(typeof(Twitter.Analyzer.Events.TweetAnalyzed), analyzerAddress);

            var endpointInstance = await Endpoint.Start(endpointConfiguration)
                                   .ConfigureAwait(false);

            try
            {
                await Task.Delay(Timeout.Infinite);
            }
            finally
            {
                await endpointInstance.Stop()
                .ConfigureAwait(false);
            }
        }
Exemplo n.º 2
0
        public static async Task Run(string nserviceBusConnectionString, string hashtag, string endpointName, string analyzerAddress)
        {
            var endpointConfiguration = new EndpointConfiguration(endpointName);

            endpointConfiguration.UseSerialization <JsonSerializer>();
            endpointConfiguration.EnableInstallers();
            endpointConfiguration.UsePersistence <NHibernatePersistence>().ConnectionString(nserviceBusConnectionString);
            endpointConfiguration.ApplyMessageConventions();
            endpointConfiguration.ApplyErrorAndAuditQueueSettings();

            var transportExtensions = endpointConfiguration.UseTransport <MsmqTransport>();

            var routing = transportExtensions.Routing();

            routing.RouteToEndpoint(typeof(AnalyzeTweet), analyzerAddress);

            var endpointInstance = await Endpoint.Start(endpointConfiguration)
                                   .ConfigureAwait(false);

            try
            {
                await Simulation.Start(endpointInstance, hashtag)
                .ConfigureAwait(false);
            }
            finally
            {
                await endpointInstance.Stop()
                .ConfigureAwait(false);
            }
        }
Exemplo n.º 3
0
        public static async Task Run(
            int maximumNumberOfTweetsPerCatchUp,
            TimeSpan defaultTransactionTimeout,
            string nserviceBusConnectionString,
            string endpointName,
            string consumerKey,
            string consumerSecret,
            string accessToken,
            string accessTokenSecret,
            string catchUpAddress,
            string analyzerAddress,
            string monitorAddress)
        {
            var endpointConfiguration = new EndpointConfiguration(endpointName);

            var transportExtensions = endpointConfiguration.UseTransport <MsmqTransport>()
                                      .Transactions(TransportTransactionMode.ReceiveOnly);

            endpointConfiguration.UnitOfWork().WrapHandlersInATransactionScope(defaultTransactionTimeout);
            endpointConfiguration.UseSerialization <JsonSerializer>();
            endpointConfiguration.EnableInstallers();
            endpointConfiguration.UsePersistence <NHibernatePersistence>().ConnectionString(nserviceBusConnectionString);
            endpointConfiguration.ApplyMessageConventions();
            endpointConfiguration.ApplyErrorAndAuditQueueSettings();
            endpointConfiguration.RegisterComponents(c => c.RegisterSingleton <ITweetService>(
                                                         new TweetService(maximumNumberOfTweetsPerCatchUp, consumerKey, consumerSecret, accessToken, accessTokenSecret)));
            endpointConfiguration.LimitMessageProcessingConcurrencyTo(1);

            var routing = transportExtensions.Routing();

            routing.RouteToEndpoint(typeof(StartCatchUp), catchUpAddress);
            routing.RouteToEndpoint(typeof(AnalyzeTweet), analyzerAddress);
            routing.RegisterPublisher(typeof(TweetReceived), monitorAddress);

            var endpointInstance = await Endpoint.Start(endpointConfiguration)
                                   .ConfigureAwait(false);

            try
            {
                await Task.Delay(Timeout.Infinite);
            }
            finally
            {
                await endpointInstance.Stop()
                .ConfigureAwait(false);
            }
        }
Exemplo n.º 4
0
        public static async Task Run(
            string nserviceBusConnectionString,
            string endpointName,
            string track,
            long tweetId,
            string catchUpAddress)
        {
            var endpointConfiguration = new EndpointConfiguration(endpointName);

            endpointConfiguration.UseSerialization <JsonSerializer>();
            endpointConfiguration.EnableInstallers();
            endpointConfiguration.UsePersistence <NHibernatePersistence>().ConnectionString(nserviceBusConnectionString);
            endpointConfiguration.ApplyMessageConventions();
            endpointConfiguration.ApplyErrorAndAuditQueueSettings();

            var transportExtensions = endpointConfiguration.UseTransport <MsmqTransport>();

            var routing = transportExtensions.Routing();

            routing.RouteToEndpoint(typeof(StartCatchUp), catchUpAddress);

            var command = new StartCatchUp
            {
                EndpointName = endpointName,
                Track        = track,
                TweetId      = tweetId,
            };

            var endpointInstance = await Endpoint.Start(endpointConfiguration)
                                   .ConfigureAwait(false);

            try
            {
                await endpointInstance.Send(command)
                .ConfigureAwait(false);
            }
            finally
            {
                await endpointInstance.Stop()
                .ConfigureAwait(false);
            }
        }
Exemplo n.º 5
0
        public static async Task Run(string nserviceBusConnectionString, string endpointName)
        {
            var endpointConfiguration = new EndpointConfiguration(endpointName);

            endpointConfiguration.UseSerialization <JsonSerializer>();
            endpointConfiguration.EnableInstallers();
            endpointConfiguration.UsePersistence <NHibernatePersistence>().ConnectionString(nserviceBusConnectionString);
            endpointConfiguration.ApplyMessageConventions();
            endpointConfiguration.ApplyErrorAndAuditQueueSettings();
            endpointConfiguration.LimitMessageProcessingConcurrencyTo(1);

            var endpointInstance = await Endpoint.Start(endpointConfiguration)
                                   .ConfigureAwait(false);

            try
            {
                await Task.Delay(Timeout.Infinite);
            }
            finally
            {
                await endpointInstance.Stop()
                .ConfigureAwait(false);
            }
        }