Beispiel #1
0
        public void CanFindAssemblyPulsers()
        {
            int ev1GeneratedCount = 0;
            int ev2GeneratedCount = 0;
            var pulsers           = Pulsers.FromAssembly(Assembly.GetExecutingAssembly()).ToList();
            EventHandler <IEnumerable <Event> > handler = (o, events) =>

                                                          events.ToList().ForEach(e =>
            {
                Console.WriteLine(e.EventType);
                if (e.EventType == "ev1-")
                {
                    ev1GeneratedCount++;
                }
                if (e.EventType == "ev2-")
                {
                    ev2GeneratedCount++;
                }
            });

            pulsers.ForEach(x =>
            {
                x.PulseGenerated += handler;
            });
            pulsers.ForEach(z => z.Start());
            Thread.Sleep(2900);
            pulsers.ForEach(z => z.Stop());

            Assert.Equal(2, ev2GeneratedCount);
            Assert.Equal(3, ev1GeneratedCount);
        }
Beispiel #2
0
        public WorkerRole()
        {
            _pulsers = Pulsers.FromAssembly(Assembly.GetAssembly(typeof(ImportFileProcessed)))
                       .ToList();


            var container = new WindsorContainer();

            _configurationValueProvider = new AzureConfigurationValueProvider();
            SetupDi(container, _configurationValueProvider, _pulsers.ToArray());
            _pulserPublisher = container.Resolve <PulserPublisher>();
            _orchestrator    = container.Resolve <Orchestrator>();

            // insert the list here
            var keyValueStore = container.Resolve <IDynamoStore>();
            var blob          = new SimpleBlob()
            {
                Body = Assembly.GetExecutingAssembly()
                       .GetManifestResourceStream("BeeHive.Sample.FileImport.Worker.Data.SampleData.txt"),
                Id           = "FileDrop/ImportFiles/SampleData.txt",
                LastModified = DateTimeOffset.Now
            };

            keyValueStore.UpsertAsync(blob);

            // add one topic that will not be created automagically by orchestrator
            // because no actor registered against it
            var q = container.Resolve <IEventQueueOperator>();

            q.CreateQueueAsync(QueueName.FromSimpleQueueName("NewIndexUpserted")).Wait();
        }
Beispiel #3
0
        /// <summary>
        /// Just a harness
        /// </summary>
        private void Can()
        {
            Console.WriteLine("{0} {1}", DateTime.Now.ToString("O"), "Starting");
            var pulsers = Pulsers.FromAssembly(Assembly.GetExecutingAssembly()).ToList();
            EventHandler <IEnumerable <Event> > handler = (o, events) =>

                                                          events.ToList().ForEach(e =>
            {
                if (e.EventType == "ev2")
                {
                    Console.WriteLine("{0} {1}", DateTime.Now.ToString("O"), e.EventType);
                }
            });

            pulsers.ForEach(x =>
            {
                x.PulseGenerated += handler;
            });
            pulsers.ForEach(z => z.Start());
            Thread.Sleep(10900);
            pulsers.ForEach(z => z.Stop());
        }
Beispiel #4
0
        public WorkerRole()
        {
            _pulsers = Pulsers.FromAssembly(Assembly.GetAssembly(typeof(NewsFeedPulsed)))
                       .ToList();


            var container = new WindsorContainer();

            _configurationValueProvider = new AzureConfigurationValueProvider();
            SetupDi(container, _configurationValueProvider, _pulsers.ToArray());
            _pulserPublisher = container.Resolve <PulserPublisher>();
            _orchestrator    = container.Resolve <Orchestrator>();

            // insert the list here
            var keyValueStore = container.Resolve <IKeyValueStore>();
            var blob          = new SimpleBlob()
            {
                Body         = new MemoryStream(Encoding.UTF8.GetBytes("http://feeds.bbci.co.uk/news/rss.xml")),
                Id           = "newsFeeds.txt",
                LastModofied = DateTimeOffset.Now
            };

            keyValueStore.UpsertAsync(blob);
        }