예제 #1
0
        public override void Run()
        {
            Trace.TraceInformation("WorkerRole1 is running");
            NewRelic.Api.Agent.NewRelic.SetTransactionName("Worker", "Run"); var watch = Stopwatch.StartNew();
            //  Start listening for actuation events from actuatorHub.
            string eventHubConnectionString = "Endpoint=sb://azureiothub.servicebus.windows.net/;SharedAccessKeyName=ReceiveRule;SharedAccessKey=6lIJjmHJRKkrEPPIPS45Su2GP2oQ2TjwvAzf2hPYr/Q=";
            string eventHubName = "actuatorhub";
            string storageAccountName = "azureiotstorage";
            string storageAccountKey = "OE8ELPPu30uc1BVRW21WH3Sb6aoTkRNbP4vmYX0eLAukYNS9prF13laVUJHQkx0hVrIeDt88a5TAwQflEcTqNg==";
            string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                storageAccountName, storageAccountKey);

            string eventProcessorHostName = Guid.NewGuid().ToString();
            eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
            Trace.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync<EventProcessor>().Wait();

            NewRelic.Api.Agent.NewRelic.RecordResponseTimeMetric("Run", watch.ElapsedMilliseconds);

            try
            {
                this.RunAsync(this.cancellationTokenSource.Token).Wait();
            }
            finally
            {
                this.runCompleteEvent.Set();
            }

        }
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            bool result = base.OnStart();

            Trace.TraceInformation("EventsForwarding OnStart()...\n");

            connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
            eventHubName = ConfigurationManager.AppSettings["Microsoft.ServiceBus.EventHubName"];

            string storageAccountName = ConfigurationManager.AppSettings["AzureStorage.AccountName"];
            string storageAccountKey = ConfigurationManager.AppSettings["AzureStorage.Key"];
            string storageAccountString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                storageAccountName, storageAccountKey);

            string iotHubConnectionString = ConfigurationManager.AppSettings["AzureIoTHub.ConnectionString"];
            iotHubServiceClient = ServiceClient.CreateFromConnectionString(iotHubConnectionString);
            eventHubClient = EventHubClient.CreateFromConnectionString(connectionString, eventHubName);

            var defaultConsumerGroup = eventHubClient.GetDefaultConsumerGroup();

            string eventProcessorHostName = "SensorEventProcessor";
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, defaultConsumerGroup.GroupName, connectionString, storageAccountString);
            eventProcessorHost.RegisterEventProcessorAsync<SensorEventProcessor>().Wait();

            Trace.TraceInformation("Receiving events...\n");

            return result;
        }
예제 #3
0
        //Event Hubsの使用
        //https://azure.microsoft.com/ja-jp/documentation/articles/event-hubs-csharp-ephcs-getstarted/
        static void Main(string[] args)
        {
            Properties.Settings settings = new Properties.Settings();

            //string eventHubConnectionString = "{Event Hub connection string}";
            //string eventHubName = "{Event Hub name}";
            string eventHubName = settings.EventHubName;
            string eventHubConnectionString = settings.EventHubConnectionString;

            //string storageAccountName = "{storage account name}";
            //string storageAccountKey = "{storage account key}";
            string storageAccountName = settings.StorageAccountName;
            string storageAccountKey = settings.StorageAccountKey;

            string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageAccountName, storageAccountKey);

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
            Console.WriteLine("Registering EventProcessor...");
            var options = new EventProcessorOptions();
            options.ExceptionReceived += (sender, e) => { Console.WriteLine(e.Exception); };
            eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>(options).Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #4
0
        public async void ReadUsingEventHubProcessor()
        {
            string serviceBusNamespace = "iotmc-ns";
            string eventHubName = "iotmc";
            string eventHubSASKeyName = "Device01";
            string eventHubSASKey = "<< Add your SAS here >>";

            string storageAccountName = "iotmc";
            string storageAccountKey = "<< add your Storage Account key here >>"; 

            string storageConnectionString = String.Format(@"DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageAccountName, storageAccountKey);
            string eventHubConnectionString = ServiceBusConnectionStringBuilder.CreateUsingSharedAccessKey(
                ServiceBusEnvironment.CreateServiceUri("sb", serviceBusNamespace, string.Empty),
                eventHubSASKeyName,
                eventHubSASKey);

            EventHubClient eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnectionString, eventHubName);
            EventHubConsumerGroup eventHubConsumerGroup = eventHubClient.GetDefaultConsumerGroup();

            EventProcessorHost eventProcessorHost = new EventProcessorHost("MSTechDemoWorker", eventHubClient.Path, eventHubConsumerGroup.GroupName, eventHubConnectionString, storageConnectionString);
            //await eventProcessorHost.RegisterEventProcessorAsync<EventHubEventProcessor>();

            //Ignore older messages even if they are still in the event hub store
            Task t = eventProcessorHost.RegisterEventProcessorAsync<EventHubEventProcessor>(new EventProcessorOptions()
            {
                InitialOffsetProvider = (partitionId) => { return DateTime.UtcNow.AddHours(-1); }
            });
            t.Wait();
        }
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            Trace.TraceInformation("Alarms has been started");

            var eventHubName = RoleEnvironment.GetConfigurationSettingValue("EventHubName");
            var serviceBusConnectionString = RoleEnvironment.GetConfigurationSettingValue("Azure.ServiceBus.ConnectionString");
            var storageConnectionString = RoleEnvironment.GetConfigurationSettingValue("Azure.Storage.ConnectionString");

            var builder = new ServiceBusConnectionStringBuilder(serviceBusConnectionString);
            builder.TransportType = TransportType.Amqp;

            var eventHubReceiveClient = EventHubClient.CreateFromConnectionString(builder.ToString(), eventHubName);

            var eventHubConsumerGroup = eventHubReceiveClient.GetDefaultConsumerGroup();

            var eventProcessorHost = new EventProcessorHost( "AlarmsWorker",
                                                             eventHubName,
                                                             eventHubConsumerGroup.GroupName,
                                                             builder.ToString(),
                                                             storageConnectionString);

            eventProcessorHost.RegisterEventProcessorAsync<MessageProcessor>();

            return base.OnStart();
        }
예제 #6
0
        public void MessageProcessingWithPartitionDistribution()
        {
            EventHubClient eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnectionString, this.eventHubName);

            // Get the default Consumer Group
            defaultConsumerGroup = eventHubClient.GetDefaultConsumerGroup();
            string blobConnectionString = ConfigurationManager.AppSettings["AzureStorageConnectionString"]; // Required for checkpoint/state
            eventProcessorHost = new EventProcessorHost("singleworker", eventHubClient.Path, defaultConsumerGroup.GroupName, this.eventHubConnectionString, blobConnectionString);
            eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>().Wait();
        }
예제 #7
0
        public void Start()
        {
            string eventProcessorHostName = Guid.NewGuid().ToString();
            eventProcessorHost = new EventProcessorHost(eventProcessorHostName, Config.EVENT_HUB_NAME,
                EventHubConsumerGroup.DefaultGroupName, Config.EVENT_HUB_CONNECTION_STRING, Config.GetStorageConnectionString());
            SimpleEventProcessor.Clients = this.Clients;
            SimpleEventProcessor.Host = eventProcessorHost;

            eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>();
        }
예제 #8
0
파일: Receiver.cs 프로젝트: tzkwizard/Azure
 public void RegisterEventProcessor(string blobConnectionString, string hostName)
 {
     EventHubClient eventHubClient = EventHubClient.CreateFromConnectionString(eventHubConnectionString,
         this.eventHubName);
     Trace.TraceInformation("register string :" + eventHubConnectionString+ blobConnectionString);
     //Use custom consumer group
     eventProcessorHost = new EventProcessorHost(hostName, eventHubClient.Path,
         EventHubConsumerGroup.DefaultGroupName, this.eventHubConnectionString, blobConnectionString);
     Trace.TraceInformation("Registering event processor");
     eventProcessorHost.RegisterEventProcessorAsync<EventProcessor>().Wait();
 }
 public async void ProcessEvents()
 {
     eventHubName = "azureguidanceevnthub";
     connectionString = GetServiceBusConnectionString();
     NamespaceManager namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
     eventHubClient = EventHubClient.CreateFromConnectionString(connectionString, eventHubName);
     defaultConsumerGroup = eventHubClient.GetDefaultConsumerGroup();
     string blobConnectionString = ConfigurationManager.AppSettings["AzureStorageConnectionString"]; // Required for checkpoint/state
     eventProcessorHost = new EventProcessorHost("AzureGuidanceReceiver", eventHubClient.Path, defaultConsumerGroup.GroupName, connectionString, blobConnectionString);
     await eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>();
                 
 }
예제 #10
0
파일: Form2.cs 프로젝트: Mecabot/ble2azure
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string eventHubConnectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
            string eventHubName = ConfigurationManager.AppSettings["EventHubName"];
            string storageConnectionString = ConfigurationManager.AppSettings["Microsoft.WindowsAzure.Storage.ConnectionString"];

            string eventProcessorHostName = Guid.NewGuid().ToString();
            eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
            eventProcessorHost.RegisterEventProcessorAsync<FEZSpiderEventHubProcessor>();
        }
예제 #11
0
        static void Main(string[] args)
        {
            string eventHubConnectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
            string eventHubName = ConfigurationManager.AppSettings["EventHubName"];
            string storageConnectionString = ConfigurationManager.AppSettings["Microsoft.WindowsAzure.Storage.ConnectionString"];

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
            eventProcessorHost.RegisterEventProcessorAsync<Pi2EventHubProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            var ehConnectionString = CloudConfigurationManager.GetSetting("ehConnectionString");
            var ehName = CloudConfigurationManager.GetSetting("ehName");
            var storageConnectionString = CloudConfigurationManager.GetSetting("azureTableConnection");

            //var storageProcHost = new EventProcessorHost(Guid.NewGuid().ToString(), ehName, "storage", ehConnectionString, storageConnectionString);
            //storageProcHost.RegisterEventProcessorAsync<StorageProcessor>().Wait();

            var entityProcHost = new EventProcessorHost(Guid.NewGuid().ToString(), ehName, "servicefabric", ehConnectionString, storageConnectionString);
            entityProcHost.RegisterEventProcessorAsync<EntityProcessor>().Wait();

            Console.ReadLine();
        }
예제 #13
0
        static void Main(string[] args)
        {
            string iotHubConnectionString = ConfigurationManager.AppSettings["iotHubConnectionString"];//"HostName={iothub-name}.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey={shared-key}";
            string iotHubD2cEndpoint = "messages/events";
            StoreEventProcessor.StorageConnectionString = ConfigurationManager.AppSettings["storageConnectionString"];// "DefaultEndpointsProtocol =https;AccountName={storage-name};AccountKey={storage-key}";
            StoreEventProcessor.ServiceBusConnectionString = ConfigurationManager.AppSettings["serviceBusConnectionString"];//"Endpoint=sb://{servicebus-name}.servicebus.windows.net/;SharedAccessKeyName={servicebus-key}";

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, iotHubD2cEndpoint, EventHubConsumerGroup.DefaultGroupName, iotHubConnectionString, StoreEventProcessor.StorageConnectionString, "messages-events");
            Console.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync<StoreEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #14
0
        static void Main(string[] args)
        {
            string storageAccountName = "bobjacapidemo";
            string storageAccountKey = "lvYpWSHkdHpCOnv91B4tGLClqeIIe0ouDW9mBAYAlm69NrHGHXhW/jrIJx5nTMgkxPWGzOoJ1jVMTCFjVvh9mg==";
            string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                storageAccountName, storageAccountKey);

            string eventHubConnectionString = "Endpoint=sb://bobjacsb.servicebus.windows.net/;SharedAccessKeyName=Receiving;SharedAccessKey=RjMnP8d1rUzYF9knM7eB3lGrV231/WAtEOCI5dI8AtM=";
            string eventProcessorHostName = Guid.NewGuid().ToString();
            string eventHubName = "apimgtdemo";
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
            eventProcessorHost.RegisterEventProcessorAsync<ApiManagementEventProcessor>().Wait();

            Console.WriteLine("Receiving.  Press enter key to stop worker.");
            Console.ReadLine();
        }
예제 #15
0
파일: Program.cs 프로젝트: richross/IoTDemo
        static void Main(string[] args)
        {
            string iotHubConnectionString = "HostName=xylotohub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=aFtv5GRYaWWtJvsTp9NETXQh8O4mqFCqxL+F0tArtM0=";
            string iotHubD2cEndpoint = "messages/events";
            StoreEventProcessor.StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=devneuzyhubsa1;AccountKey=idRO5Eetw3XbdkFRUwtwPhlOuwe2xBPgsv3WjyhknyR0RzstIb7jyDc+R4cWfEhaRuWMZ9NA+uvGQhB5rIfeEw==;BlobEndpoint=https://devneuzyhubsa1.blob.core.windows.net/;TableEndpoint=https://devneuzyhubsa1.table.core.windows.net/;QueueEndpoint=https://devneuzyhubsa1.queue.core.windows.net/;FileEndpoint=https://devneuzyhubsa1.file.core.windows.net/";
            StoreEventProcessor.ServiceBusConnectionString = "Endpoint=sb://devneuzyhubsb2.servicebus.windows.net/;SharedAccessKeyName=send;SharedAccessKey=KXm1zyrKJ+3cuFL5junQfJw5hXEkEgOVzaGhcoFt7fA=";

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, iotHubD2cEndpoint, EventHubConsumerGroup.DefaultGroupName, iotHubConnectionString, StoreEventProcessor.StorageConnectionString, "messages-events");
            Console.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync<StoreEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #16
0
        static void Main(string[] args)
        {
            string eventHubConnectionString = "讀取原則的連接字串";
              string eventHubName = "事件中樞名稱";
              string storageAccountName = "儲存體帳戶名稱";
              string storageAccountKey = "儲存體存取金鑰";
              string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                  storageAccountName, storageAccountKey);

              string eventProcessorHostName = Guid.NewGuid().ToString();
              EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
              eventProcessorHost.RegisterEventProcessorAsync<ReceiveProcessor>().Wait();

              Console.WriteLine("Receiving.Press enter key to stop worker.");
              Console.ReadLine();
        }
예제 #17
0
파일: Program.cs 프로젝트: danvy/sigfox
 public static void Main()
 {
     var eventHubName = "alert";
     var consumerGroup = "email";
     var eventProcessorName = "EmailAlertProcessor";
     var busConnectionString = ConfigurationManager.ConnectionStrings["SigfoxDemoAlertListener"].ConnectionString;
     var storageConnectionString = ConfigurationManager.ConnectionStrings["SigfoxDemoStorage"].ConnectionString;
     if (!WebJobsHelper.RunAsWebJobs)
         Console.CancelKeyPress += Console_CancelKeyPress;
     EventHubClient eventHubClient = null;
     var retries = 3;
     while (retries > 0)
     {
         try
         {
             retries--;
             eventHubClient = EventHubClient.CreateFromConnectionString(busConnectionString, eventHubName);
             retries = 0;
         }
         catch (Exception e)
         {
             Console.Error.WriteLine("Error opening source Event Hub: " + e.Message);
             if (retries == 0)
                 throw;
         }
     }
     if (consumerGroup == null)
         consumerGroup = eventHubClient.GetDefaultConsumerGroup().GroupName;
     var eventProcessorHost = new EventProcessorHost(eventProcessorName, eventHubClient.Path,
         consumerGroup, busConnectionString, storageConnectionString, eventHubName.ToLowerInvariant());
     eventProcessorHost.RegisterEventProcessorAsync<EventProcessor>().Wait();
     while (true)
     {
         if (WebJobsHelper.RunAsWebJobs)
         {
             Thread.Sleep(50);
         }
         else
         {
             Console.WriteLine("Waiting for new messages " + DateTime.UtcNow);
             Thread.Sleep(1000);
         }
         if (quit || WebJobsHelper.NeedShutdown)
             break;
     }
     eventProcessorHost.UnregisterEventProcessorAsync().Wait();
 }
예제 #18
0
        static void Main(string[] args)
        {
            string eventHubConnectionString = "Endpoint=sb://gftesthub-ns.servicebus.windows.net/;SharedAccessKeyName=ReceiveRule;SharedAccessKey=wEO+aZpuPDKDp4Z8zBUlbLQ5CEhEtBqKfjztpo5MM3Y=";
            string eventHubName = "gftesthub";
            string storageAccountName = "gfeventhubstorage";
            string storageAccountKey = "DkOjsj/2NSWY62+N79+kJbR9EvPk5seonYab5U5g95n4qfKvPUPVAqNPY7R3QdX64HBomXmsCfBQIH6HMHABIw==";
            string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageAccountName, storageAccountKey);

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
            Console.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
        public void ProcessMessages(ref EventProcessorHost host, ref object thelock, ref bool registered, bool active)
        {
            ServicePointManager.DefaultConnectionLimit = 12;

            lock (thelock)
            {
                if (active)
                {
                    if (!registered)
                    {
                        try
                        {
                            EventProcessorOptions options = new EventProcessorOptions();
                            options.InitialOffsetProvider = (partitionId) => DateTime.UtcNow;

                            host.RegisterEventProcessorAsync<MessageProcessor>(options).Wait();
                            registered = true;
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message);
                            registered = false;
                        }
                    }
                }
                else
                {
                    if (registered)
                    {
                        try
                        {
                            host.UnregisterEventProcessorAsync().Wait();
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message);
                        }
                        finally
                        {
                            registered = false;
                        }
                    }
                }
            }
        }
예제 #20
0
        static void Main(string[] args)
        {
            string eventHubConnectionString = "{Endpoint=sb://infotron-ns.servicebus.windows.net/;SharedAccessKeyName=ReceiveRule;SharedAccessKey=qHLYZvpuX2aBLijgkLJew4CpdUEPHlt6BSLQ/8ZjELU=}";
              string eventHubName = "{infotron}";
              string storageAccountName = "{infotroneventhubstorage}";
              string storageAccountKey = "{+QJ2u4jJNKaU9EUcFGlHa2yWQOTZjrRHF3DS4ZmpoJYfPIydqvAKj7MouytLnvR/1qdaUSc1rrNBeHtQbBeaYQ==}";
              string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
              storageAccountName, storageAccountKey);

              string eventProcessorHostName = Guid.NewGuid().ToString();
              EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
              Console.WriteLine("Registering EventProcessor...");
              eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>().Wait();

              Console.WriteLine("Receiving. Press enter key to stop worker.");
              Console.ReadLine();
              eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
        /*
        async Task SetupStoring()
        {
            EventHubClient eventHubClient = EventHubClient.CreateFromConnectionString(CS_EVENTHUB, NAME_EVENTHUB);

            var nsManager = NamespaceManager.CreateFromConnectionString(CS_EVENTHUB);
            var ehDesc = await nsManager.GetEventHubAsync(NAME_EVENTHUB);
            var storeCGDesc = await nsManager.CreateConsumerGroupIfNotExistsAsync(NAME_EVENTHUB, STORE_CONSUMER_GROUP_NAME);
            var storeCG = eventHubClient.GetConsumerGroup(STORE_CONSUMER_GROUP_NAME);

            var epHost = new EventProcessorHost(NAMESPACE_EVENTHUB, NAME_EVENTHUB, STORE_CONSUMER_GROUP_NAME, CS_EVENTHUB, CS_MOBILE_SERVICE);
            await epHost.RegisterEventProcessorAsync<SensorEventProcessor>();
        }*/

        async Task SetupStoring()
        {
            SensorEventProcessor.StartedTime = DateTime.UtcNow;

            var storeCS = CloudConfigurationManager.GetSetting("StorageConnectionString");
            var storageAccount = CloudStorageAccount.Parse(storeCS);

            var eventHubCS = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            var ehClient = EventHubClient.CreateFromConnectionString(eventHubCS, NAME_EVENTHUB);

            var nsManager = NamespaceManager.CreateFromConnectionString(eventHubCS);
            var ehDesc = await nsManager.GetEventHubAsync(NAME_EVENTHUB);
            var storeCGDesc = await nsManager.CreateConsumerGroupIfNotExistsAsync(NAME_EVENTHUB, STORE_CONSUMER_GROUP_NAME);
            var storeCG = ehClient.GetConsumerGroup(STORE_CONSUMER_GROUP_NAME);

            var epHost = new EventProcessorHost(NAMESPACE_EVENTHUB, NAME_EVENTHUB, STORE_CONSUMER_GROUP_NAME, eventHubCS, storeCS);
            await epHost.RegisterEventProcessorAsync<SensorEventProcessor>();
        }
예제 #22
0
        private async Task RunAsync(CancellationToken cancellationToken)
        {
            var builder = IotHubConnectionStringBuilder.Create(iotHubConnectionString);
            var hubName = builder.HostName.Split('.')[0];
            string eventHubPath = "messages/events";
            host = new EventProcessorHost("Worker RoleId: " + RoleEnvironment.CurrentRoleInstance.Id,
                eventHubPath, "cloudservice", iotHubConnectionString,
                storageConnectionString,"messagesevents");

            await host.RegisterEventProcessorAsync<EventProcessor>(new EventProcessorOptions {
                InitialOffsetProvider = (partition) => DateTime.UtcNow
            });
            while (!cancellationToken.IsCancellationRequested)
            {
                //Trace.TraceInformation("Working");
                await Task.Delay(1000);
            }
        }
예제 #23
0
파일: Program.cs 프로젝트: mindis/AzurePlay
        static void Main(string[] args)
        {
            string eventHubConnectionString = "<reader connection string>";
            string eventHubName = "<hub name>";
            string storageAccountName = "<storage account name";
            string storageAccountKey = "<storage account key>";
            string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
            storageAccountName, storageAccountKey);

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
            Console.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #24
0
        private static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration().WriteTo.ColoredConsole().CreateLogger();

            var eventHubConnectionString = ConfigurationManager.AppSettings["EventHubConnectionString"];
            var eventHubName = ConfigurationManager.AppSettings["EventHubName"];
            var storageAccountName = ConfigurationManager.AppSettings["StorageAccountName"];
            var storageAccountKey = ConfigurationManager.AppSettings["StorageAccountKey"];
            var storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                storageAccountName, storageAccountKey);
            var eventProcessorHostName = Guid.NewGuid().ToString();
            var eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName,
                EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
            eventProcessorHost.RegisterEventProcessorAsync<EventProcessor>().Wait();

            Log.Logger.Information("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
        }
예제 #25
0
        static void Main(string[] args)
        {
            string eventHubConnectionString = "{Endpoint=sb://infotron-ns.servicebus.windows.net/;SharedAccessKeyName=ReceiveRule;SharedAccessKey=qHLYZvpuX2aBLijgkLJew4CpdUEPHlt6BSLQ/8ZjELU=}";
            string eventHubName             = "{infotron}";
            string storageAccountName       = "{infotroneventhubstorage}";
            string storageAccountKey        = "{+QJ2u4jJNKaU9EUcFGlHa2yWQOTZjrRHF3DS4ZmpoJYfPIydqvAKj7MouytLnvR/1qdaUSc1rrNBeHtQbBeaYQ==}";
            string storageConnectionString  = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                                                            storageAccountName, storageAccountKey);

            string             eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost     = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);

            Console.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #26
0
        private static async Task MainAsync(string[] args)
        {
            Console.WriteLine("Registering EventProcessor...");

            var eventProcessorHost = new EventProcessorHost(
                EventHubName,
                PartitionReceiver.DefaultConsumerGroupName,
                EventHubConnectionString,
                StorageConnectionString,
                StorageContainerName);

            // Registers the Event Processor Host and starts receiving messages
            await eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>();

            Thread.Sleep(Timeout.Infinite);

            // Disposes of the Event Processor Host
            await eventProcessorHost.UnregisterEventProcessorAsync();
        }
예제 #27
0
        static void Main(string[] args)
        {
            try
            {
                //Use a unique name if you are running more than one
                var processorId = string.Format("Reader:{0}-{1}", Environment.MachineName, Guid.NewGuid());
                //var processorId = Environment.MachineName;

                var host = new EventProcessorHost(processorId, eventHubName, consumerGroupName, eventHubConnString, storageConnString);
                //host.RegisterEventProcessorAsync<TpmsPressureProcessor>();
                host.RegisterEventProcessorAsync <TpmsPressureProcessor>().Wait();
                Console.WriteLine("Begin reading messages with processor id [{0}].", processorId);
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("An erorr occured registering th reader " + ex.ToString());
            }
        }
예제 #28
0
        static async Task MainAsync(string[] args)
        {
            Console.WriteLine("Registering EventProcessor...");

            var eventHubConnection      = _config["EventHubConnection"];
            var eventHubName            = _config["EventHubName"];
            var storageContainerName    = _config["StorageContainerName"];
            var storageAccountName      = _config["StorageAccountName"];
            var storageAccountKey       = _config["StorageAccountKey"];
            var storageConnectionString = _config["StorageConnectionString"];

            var eventProcessorHost = new EventProcessorHost(eventHubName, PartitionReceiver.DefaultConsumerGroupName, eventHubConnection, storageConnectionString, storageContainerName);
            await eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>();

            Console.WriteLine("Receiving. Press ENTER to stop worker.");
            Console.ReadLine();

            await eventProcessorHost.UnregisterEventProcessorAsync();
        }
예제 #29
0
        public static void ReceivePartitionMessage()
        {
            string storageAccountName = "elsaotuo";
            string storageAccountKey =
                "AV49N0PZ1Qlz42b0w47EPoPbNLULgxYOWxsO4IvFmrAkZPzkdGCKKOJqyiHVGfAPex6HhkDSWpNQAIuPmBHBMA==";
            string storageConnectionString =
                String.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                    storageAccountName, storageAccountKey);

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost("1", eventHubName,
                EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
            Console.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync<EventProcessor>(new EventProcessorOptions()
            {
                //InitialOffsetProvider = (partitionId) => DateTime.UtcNow
            }).Wait();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #30
0
        private static async Task MainAsync()
        {
            Console.WriteLine($"Register the {nameof(WiredBrainCoffeeEventProcessor)}");

            var eventProcessorHost = new EventProcessorHost(
                eventHubPath,
                consumerGroupName,
                eventHubConnectionString,
                storageConnectionString,
                leaseContainerName);

            await eventProcessorHost.RegisterEventProcessorAsync <WiredBrainCoffeeEventProcessor>();

            Console.WriteLine("Waiting for incoming events...");
            Console.WriteLine("Press any key to shutdown");
            Console.ReadLine();

            await eventProcessorHost.UnregisterEventProcessorAsync();
        }
예제 #31
0
        private static async Task startReceiver()
        {
            System.Diagnostics.Debug.WriteLine("Registering EventProcessor...");

            var eventProcessorHost = new EventProcessorHost(
                EhEntityPath,
                PartitionReceiver.DefaultConsumerGroupName,
                EhConnectionString,
                StorageConnectionString,
                StorageContainerName);

            // Registers the Event Processor Host and starts receiving messages
            await eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>();

            System.Diagnostics.Debug.WriteLine("Receiving. Press ENTER to stop worker.");

            // Disposes of the Event Processor Host
            //await eventProcessorHost.UnregisterEventProcessorAsync();
        }
예제 #32
0
        private static void Main()
        {
            var storageConnectionString =
                $"DefaultEndpointsProtocol=https;AccountName={StorageAccountName};AccountKey={StorageAccountKey}";

            var eventProcessorHostName = Guid.NewGuid().ToString();
            var eventProcessorHost     = new EventProcessorHost(eventProcessorHostName, EventHubName, EventHubConsumerGroup.DefaultGroupName, EventHubConnectionString, storageConnectionString);

            Console.WriteLine("Registering EventProcessor...");

            var options = new EventProcessorOptions();

            options.ExceptionReceived += (sender, e) => { Console.WriteLine(e.Exception); };
            eventProcessorHost.RegisterEventProcessorAsync <MyFirstEventProcessor>(options).Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #33
0
        static void Main(string[] args)
        {
            string eventHubConnectionString = "Endpoint=sb://eh-demo.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=shihzPAai4oz8A9ZEYVxm6FvAuPszO+jx7683yYhkS0=";
            string eventHubName             = "eh-example";
            string storageConnectionString  = "DefaultEndpointsProtocol=https;AccountName=stehdemo;AccountKey=smc73oUiyJzWk045+QMbFjY9umOVmnRpZhxTTTm2rnWpQA1wprBGITbCjlKtruPr192RB0enyoNmo9K4bJblzg==";

            string             eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost     = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);

            Console.WriteLine("Registering EventProcessor...");
            var options = new EventProcessorOptions();

            options.ExceptionReceived += (sender, e) => { Console.WriteLine(e.Exception); };
            eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>(options).Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #34
0
        private static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration().WriteTo.ColoredConsole().CreateLogger();

            var eventHubConnectionString = ConfigurationManager.AppSettings["EventHubConnectionString"];
            var eventHubName             = ConfigurationManager.AppSettings["EventHubName"];
            var storageAccountName       = ConfigurationManager.AppSettings["StorageAccountName"];
            var storageAccountKey        = ConfigurationManager.AppSettings["StorageAccountKey"];
            var storageConnectionString  = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                                                         storageAccountName, storageAccountKey);
            var eventProcessorHostName = Guid.NewGuid().ToString();
            var eventProcessorHost     = new EventProcessorHost(eventProcessorHostName, eventHubName,
                                                                EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);

            eventProcessorHost.RegisterEventProcessorAsync <EventProcessor>().Wait();

            Log.Logger.Information("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
        }
예제 #35
0
        public async void StartEventHub()
        {
            Console.WriteLine("Registering EventProcessor...");

            funnelDataObject = createTdsDataObject("funnel");
            beamDataObject   = createTdsDataObject("beam");



            eventProcessorHost = new EventProcessorHost(
                EventHubName,
                PartitionReceiver.DefaultConsumerGroupName,
                EventHubConnectionString,
                StorageConnectionString,
                StorageContainerName);

            // Registers the Event Processor Host and starts receiving messages
            await eventProcessorHost.RegisterEventProcessorAsync <SoracomEventProcessor>();
        }
예제 #36
0
        static void Receive()
        {
            try
            {
                string hostName = Guid.NewGuid().ToString();

                //single partition
                //string eventHubPath = "demo001";

                //multi partition
                string eventHubPath = "demo001multipartition";

                string consumerGroup = PartitionReceiver.DefaultConsumerGroupName;

                //single partition
                //string eventHubConnectionString = "Endpoint=sb://mgr-evo.servicebus.windows.net/;SharedAccessKeyName=Subscriber;SharedAccessKey=Gh0ovVawNx5OeAOsY6iErfcNKvjPOhJgq2aDV1E8f+c=;EntityPath=demo001";

                //multi partition
                string eventHubConnectionString = "Endpoint=sb://mgr-evo.servicebus.windows.net/;SharedAccessKeyName=Consumer;SharedAccessKey=pKdh2Gihj1VeUxuEziOvi5F768HF+IZ7oXit/aXpVh8=;EntityPath=demo001multipartition";


                string             storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=ave21corestorage;AccountKey=4DtEkomn9JV1BjMODFmtm9VRnzuAkhVejm3rEXhMCWVBq5Z8KaNkU0ZbC4DsgKx4fxeZ1SKm/a1jN/FGCC95gg==;EndpointSuffix=core.windows.net;";
                string             storageContainerName    = "eventhubtest";
                EventProcessorHost eventProcessorHost      = new EventProcessorHost(
                    hostName: hostName,
                    eventHubPath: eventHubPath,
                    consumerGroupName: consumerGroup,
                    eventHubConnectionString: eventHubConnectionString,
                    storageConnectionString: storageConnectionString,
                    storageContainerName
                    );
                EventProcessorOptions options = new EventProcessorOptions();
                eventProcessorHost.RegisterEventProcessorAsync <Consumer>(options);

                Console.WriteLine("Press ENTER to quit");
                Console.ReadLine();
                eventProcessorHost.UnregisterEventProcessorAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
예제 #37
0
        private static async Task MainAsync(string[] args)
        {
            Console.WriteLine("Registering EventProcessor...");

            var eventProcessorHost = new EventProcessorHost(
                EventHubName,
                PartitionReceiver.DefaultConsumerGroupName,
                EventHubConnectionString,
                StorageConnectionString);

            // Registers the Event Processor Host and starts receiving messages
            await eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>();

            Console.WriteLine("Receiving. Press ENTER to stop worker.");
            Console.ReadLine();

            // Disposes of the Event Processor Host
            await eventProcessorHost.UnregisterEventProcessorAsync();
        }
예제 #38
0
        static async Task MainAsyncTask()
        {
            Console.WriteLine("Registering event processor");
            var eventProcessorhost = new EventProcessorHost
                                     (
                Event_Hub_Name,
                PartitionReceiver.DefaultConsumerGroupName,
                Event_Hub_Connection_string,
                Storage_Account_Connection_String,
                Storage_Container_Name
                                     );

            await eventProcessorhost.RegisterEventProcessorAsync <SimpleEventProcessor>();

            Console.WriteLine("Receiving messages, press enter to stop the worker");
            Console.ReadLine();

            await eventProcessorhost.UnregisterEventProcessorAsync();
        }
예제 #39
0
        static void Main(string[] args)
        {
            string             eventHubConnectionString = "{Event Hubs namespace connection string}";
            string             eventHubName             = "{Event Hub name}";
            string             storageAccountName       = "{storage account name}";
            string             storageAccountKey        = "{storage account key}";
            string             storageConnectionString  = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageAccountName, storageAccountKey);
            string             eventProcessorHostName   = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost       = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);

            Console.WriteLine("Registering EventProcessor...");
            var options = new EventProcessorOptions();

            options.ExceptionReceived += (sender, e) => { Console.WriteLine(e.Exception); };
            eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>(options).Wait();
            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #40
0
        static void Main(string[] args)
        {
            string iotHubConnectionString = "{iot hub connection string}";
            string iotHubD2cEndpoint = "messages/events";
            StoreEventProcessor.StorageConnectionString = "{storage connection string}";
            StoreEventProcessor.ServiceBusConnectionString = "{service bus send connection string}";


            StoreEventProcessor.QueueName = "softdatiot";

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, iotHubD2cEndpoint, EventHubConsumerGroup.DefaultGroupName, iotHubConnectionString, StoreEventProcessor.StorageConnectionString, "messages-events");
            Console.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync<StoreEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #41
0
        private static async Task RegisterEventUsingAsync(string[] args)
        {
            Console.WriteLine("Registering EventProcessor...");

            var eventProcessorHost = new EventProcessorHost(
                EntityPath,
                PartitionReceiver.DefaultConsumerGroupName,
                ConnectionString,
                StorageConnectionString,
                StorageContainerName);

            await eventProcessorHost.RegisterEventProcessorAsync <EventHubReceiver>();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();

            // Disposes of the Event Processor Host
            await eventProcessorHost.UnregisterEventProcessorAsync();
        }
        private static async Task MainAsync(string[] args)

        {
            Console.WriteLine("Registering EventProcessor...");



            var eventProcessorHost = new EventProcessorHost(

                EventHubName,

                EventHubConsumerGroup,

                EventHubConnectionString,

                StorageConnectionString,

                StorageContainerName);

            var options = new EventProcessorOptions()
            {
                MaxBatchSize   = 200,
                PrefetchCount  = 300,
                ReceiveTimeout = TimeSpan.FromMinutes(1),
                EnableReceiverRuntimeMetric        = true,
                InvokeProcessorAfterReceiveTimeout = false
            };

            //Implement a class with name SimpleEventProcessor inheriting IEventProcessor

            await eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>(options);



            Console.ReadLine();



            // Disposes of the Event Processor Host

            await eventProcessorHost.UnregisterEventProcessorAsync();
        }
예제 #43
0
        private static async Task MainAsync(string[] args)
        {
            Console.WriteLine("Registering EventProcessor...");

            var builder = new ConfigurationBuilder()
                          .AddEnvironmentVariables();
            var configuration = builder.Build();

            var connectionString = configuration["EVENTHUB_READER_CONNECTION_STRING"];
            int entityPathIndex  = connectionString.IndexOf("EntityPath=", StringComparison.Ordinal);

            connectionString = connectionString.Substring(0, entityPathIndex);

            var eventHubPath       = configuration["EVENTHUB_READER_PATH"];
            var storageAccountName = configuration["STORAGE_ACCOUNT_NAME"];
            var storageAccountKey  = configuration["STORAGE_ACCOUNT_KEY"];

            var storageConnectionString = $"DefaultEndpointsProtocol=https;AccountName={storageAccountName};" +
                                          $"AccountKey={storageAccountKey};EndpointSuffix=core.windows.net";

            Console.WriteLine($"Connecting with connString: { connectionString }");
            Console.WriteLine($"Connecting with eventHubPath: { eventHubPath }");
            Console.WriteLine($"Connecting with storageAccName: { storageAccountName }");
            Console.WriteLine($"Connecting with storageAccKey: { storageAccountKey }");
            Console.WriteLine($"Connecting with storageConnString: { storageConnectionString }");

            var eventProcessorHost = new EventProcessorHost(
                eventHubPath,
                PartitionReceiver.DefaultConsumerGroupName,
                connectionString,
                storageConnectionString,
                "hostsync");

            // Registers the Event Processor Host and starts receiving messages
            var eventProcessorOptions = EventProcessorOptions.DefaultOptions;

            eventProcessorOptions.MaxBatchSize  = 1000;
            eventProcessorOptions.PrefetchCount = 1000;
            await eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>(eventProcessorOptions);

            await Task.Delay(Timeout.Infinite);
        }
예제 #44
0
        private static async Task MainAsync(string[] args)
        {
            Console.WriteLine("Registering EventProcessor...");

            var eventProcessorHost = new EventProcessorHost(
                EhEntityPath,
                "tests",
                EhConnectionString,
                StorageConnectionString,
                StorageContainerName);

            // Registers the Event Processor Host and starts receiving messages
            await eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>();

            Console.WriteLine("Receiving. Press ENTER to stop worker.");
            Console.ReadLine();

            // Disposes of the Event Processor Host
            await eventProcessorHost.UnregisterEventProcessorAsync();
        }
예제 #45
0
        static void Main(string[] args)
        {
            string iotHubConnectionString = "HostName=hhnext.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=jjHgtQz3AtfnTn6p/I5zH9POHLg9f55WnYlPD4y0Sqw=";
            string iotHubD2cEndpoint      = "messages/events";

            StoreEventProcessor.StorageConnectionString    = "DefaultEndpointsProtocol=https;AccountName=hhnext;AccountKey=taWiGCrW5t0zmb2gjGcR3Dzy3t47B8BV2V9ibX0thturZGCYDHxlVOHx/ZRQ+8mYSAffaWxoxTjlvXt5kdThBA==;";
            StoreEventProcessor.ServiceBusConnectionString =
                "Endpoint=sb://hhnext.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=9HTDDNPcUjr4fNYRf1//VWRVh/k0a4b/tifTCEvwZjw=";

            string             eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost     = new EventProcessorHost(eventProcessorHostName, iotHubD2cEndpoint, EventHubConsumerGroup.DefaultGroupName, iotHubConnectionString, StoreEventProcessor.StorageConnectionString, "messages-events");

            Console.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync <StoreEventProcessor>().Wait();

            Console.WriteLine("Receiving ,  Press enter key to stop worker.");
            Console.ReadLine();

            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #46
0
        static void Main(string[] args)
        {
            storageConnectionString = ConfigurationManager.AppSettings["StorageConnectionString"].ToString();
            iotHubconnectionString  = ConfigurationManager.AppSettings["IoTHubConnectionString"].ToString();
            iotHubD2cEndpoint       = ConfigurationManager.AppSettings["IoTHubD2cEndpoint"].ToString();

            string eventProcessorHostName = Guid.NewGuid().ToString();

            //Initializes a new instance of the Microsoft.ServiceBus.Messaging.EventProcessorHost
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, iotHubD2cEndpoint, EventHubConsumerGroup.DefaultGroupName,
                                                                           iotHubconnectionString, storageConnectionString, "messages-events");

            Console.WriteLine("Registering EventProcessor...");

            eventProcessorHost.RegisterEventProcessorAsync <IOTEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #47
0
        private async static Task MainAsync()
        {
            Console.WriteLine("Registering EventProcessor...");
            var eventHubConnectionString = $"Endpoint=sb://event-hub-examples.servicebus.windows.net/;SharedAccessKeyName={SHARED_ACCESS_KEY_NAME};SharedAccessKey={SHARED_ACCESS_KEY}";
            var eventProcessorHost       = new EventProcessorHost(
                EVENT_HUB_NAME,
                PartitionReceiver.DefaultConsumerGroupName,
                eventHubConnectionString,
                StorageConnectionString,
                STORAGE_CONTAINER_NAME);

            // Registers the Event Processor Host and starts receiving messages
            await eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>();

            Console.WriteLine("Receiving. Press ENTER to stop worker.");
            Console.ReadLine();

            // Disposes of the Event Processor Host
            await eventProcessorHost.UnregisterEventProcessorAsync();
        }
예제 #48
0
        static void Main(string[] args)
        {
            string eventHubConnectionString = "Endpoint=sb://apimgeventhub.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=d9wyzbY7nQ8CSNlto2Vnj44wDN6qqe1INBVf14jPeoc=";
            string eventHubName             = "testeventhub";
            string storageAccountName       = "apimgpocstorage";
            string storageAccountKey        = "zF8S8hqx7b43fG4zeNLc8BVC80A6E6qQz5JIGCev5RWhOaT9dDmHS9gqoWons3uUHCHVotgxMyGO3y/Ejbb0kQ==";
            string storageConnectionString  = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageAccountName, storageAccountKey);

            string             eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost     = new EventProcessorHost(eventHubName, PartitionReceiver.DefaultConsumerGroupName, eventHubConnectionString, storageConnectionString, "calculatorlogcontainer");

            Console.WriteLine("Registering EventProcessor...");
            //var options = new EventProcessorOptions();
            //options.ExceptionReceived += (sender, e) => { Console.WriteLine(e.Exception); };
            eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #49
0
        public static void SetupEventProcessorHost(string connectionString, string eventHubPath, string consumerGroupName, string storageConnectionString, string leaseContainerName)
        {
            host = new EventProcessorHost(eventHubPath,
                                          consumerGroupName,
                                          connectionString,
                                          storageConnectionString,
                                          leaseContainerName
                                          );

            host.RegisterEventProcessorAsync <SimpleEventProcessor>(new EventProcessorOptions
            {
                InitialOffsetProvider = (partitionId) =>
//EventPosition.FromSequenceNumber(msgSqNm)
//EventPosition.FromEnd()
//EventPosition.FromEnqueuedTime(DateTime.UtcNow)
//EventPosition.FromOffset(offsetString, !skipThisOneAndGoToNext)
//EventPosition.FromSequenceNumber(msgSqNm)
                                        EventPosition.FromStart()
            });
        }
예제 #50
0
        static void Main(string[] args)
        {
            string eventHubConnectionString = ConfigurationManager.AppSettings["eventHubReceiveRuleConnectionString"];
            string eventHubName = ConfigurationManager.AppSettings["eventHubName"];
            string storageAccountName = ConfigurationManager.AppSettings["storageAccountName"];
            string storageAccountKey = ConfigurationManager.AppSettings["storageAccountKey"];
            string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageAccountName, storageAccountKey);

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);

            Console.WriteLine("Registering EventProcessor...");
            var options = new EventProcessorOptions();
            options.ExceptionReceived += (sender, e) => { Console.WriteLine(e.Exception); };
            eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>(options).Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #51
0
        static void Main(string[] args)
        {
            string eventHubConnectionString = "Endpoint=sb://v11-test.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=vsGHhkWdKA2uukXjUmgmRpMcsnj2315HOZhd3EuWw/8=";
            string eventHubName             = "wanwutest";
            string storageAccountName       = "v11";
            string storageAccountKey        = "e41T5FjeDOyYgAE23HAgBhoOeZVnlm/ITbVz2mhiUtF8yOq43tJXly1VxWfaGb0v5KK5+E0oe3eZBA/LNYvu3Q==";
            string storageConnectionString  = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageAccountName, storageAccountKey);

            string             eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost     = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);

            Console.WriteLine("Registering EventProcessor...");
            //var options = new EventProcessorOptions();
            //options.ExceptionReceived += (sender, e) => { Console.WriteLine(e.Exception); };
            eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #52
0
        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            var host = new JobHost();
            string iotHubConnectionString = ConfigurationManager.AppSettings["iotHubConnectionString"];

            //https://azure.microsoft.com/en-us/documentation/articles/iot-hub-devguide/#endpoints
            string iotHubD2cEndpoint = "messages/events";
            SKSEventProcessor.StorageConnectionString = ConfigurationManager.AppSettings["storageConnectionString"];
            SKSEventProcessor.ServiceBusConnectionString = ConfigurationManager.AppSettings["serviceBusConnectionString"];

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, iotHubD2cEndpoint, EventHubConsumerGroup.DefaultGroupName, iotHubConnectionString, SKSEventProcessor.StorageConnectionString,"messages-events");

            Console.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync<SKSEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            host.RunAndBlock();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #53
0
        private static void Main(string[] args)
        {
            var settings = JObject.Parse(File.ReadAllText("env.vars"));

            var storageConnectionString  = string.Format(storageConnectionStringTemplate, settings["storage"]["name"], settings["storage"]["sak"]);
            var eventHubConnectionString = string.Format(eventHubConnectionStringTemplate, settings["iot"]["eh_endpoint"], settings["iot"]["service_sap"], settings["iot"]["name"]);

            var eventProcessorHost = new EventProcessorHost(
                settings["iot"]["name"].ToString(),
                PartitionReceiver.DefaultConsumerGroupName,
                eventHubConnectionString,
                storageConnectionString,
                "event-processor");

            eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>().Wait();


            Console.WriteLine("Press ENTER to stop SERVICE LISTENER simulator");
            Console.ReadLine();
        }
        public static void Main(string[] args)
        {
            Console.WriteLine("Registering EventProcessor...");

            var eventProcessorHost = new EventProcessorHost(
                EhEntityPath,
                PartitionReceiver.DefaultConsumerGroupName,
                EhConnectionString,
                StorageConnectionString,
                StorageContainerName);

            // Registers the Event Processor Host and starts receiving messages
            eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();

            // Disposes of the Event Processor Host
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #55
0
        static void Main(string[] args)
        {
            Console.WriteLine("Waiting for Orleans Silo to start. Press Enter to proceed...");
            Console.ReadLine();

            GrainClient.Initialize("ClientConfiguration.xml");

            var ehConnectionString      = CloudConfigurationManager.GetSetting("ehConnectionString");
            var ehName                  = CloudConfigurationManager.GetSetting("ehName");
            var storageConnectionString = CloudConfigurationManager.GetSetting("azureTableConnection");

            //var storageProcHost = new EventProcessorHost(Guid.NewGuid().ToString(), ehName, "forstorage", ehConnectionString, storageConnectionString);
            //storageProcHost.RegisterEventProcessorAsync<StorageProcessor>().Wait();

            var entityProcHost = new EventProcessorHost(Guid.NewGuid().ToString(), ehName, "fororleans", ehConnectionString, storageConnectionString);

            entityProcHost.RegisterEventProcessorAsync <EntityProcessor>().Wait();

            Console.ReadLine();
        }
예제 #56
0
        private static async Task ProcessEvents()
        {
            Console.WriteLine("Registering EventProcessor...");

            var eventProcessorHost = new EventProcessorHost(
                Configuration["ParrotEventHubEntityPath"],
                PartitionReceiver.DefaultConsumerGroupName,
                Configuration["ParrotEventHubReceiverConnectionString"],
                Configuration["ConnectionString"],
                Configuration["ParrotEventHubReceiverEventProcessorHostContainer"]);

            // Registers the Event Processor Host and starts receiving messages
            await eventProcessorHost.RegisterEventProcessorAsync <SimpleEventProcessor>();

            Console.WriteLine("Receiving. Press ENTER to stop worker.");
            Console.ReadLine();

            // Disposes of the Event Processor Host
            await eventProcessorHost.UnregisterEventProcessorAsync();
        }
예제 #57
0
        static void Main(string[] args)
        {
            string eventHubName = "myeventhub";
               string eventHubConnectionString =
                "Endpoint=sb://myeventhub-johnson.servicebus.windows.net/;SharedAccessKeyName=ListenKeyMyEventHub;SharedAccessKey=bdIVbIb/zpblWEXtTVRWs0wfL/tPKyMFyPWI9+9PFP8=";

            string storageAccountName = "jwwas";
            string storageAccountKey = "cKBEo0jEgIDq7qApSr0KRNP+lD+yOylDomrpfI9CNrhfAeQwW0iE+/UAlX9A7sAcFn5Phm3muu9Qs2igBqRNfA==";
            string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                storageAccountName, storageAccountKey);

            string eventProcessorHostName = Guid.NewGuid().ToString();
            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName, eventHubName, EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);
            Console.WriteLine("Registering EventProcessor...");
            eventProcessorHost.RegisterEventProcessorAsync<SimpleEventProcessor>().Wait();

            Console.WriteLine("Receiving. Press enter key to stop worker.");
            Console.ReadLine();
            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #58
0
        static void Main(string[] args)
        {
            if (args.Length < 11)
            {
                WriteUsage();
                return;
            }



            string eventHubConnectionString  = "{Event Hub Connection String}";
            string eventHubName              = "{EventHub Name}";
            string eventHubConsumerGroupName = "{Event Hub Consumer Name}";
            string storageAccountName        = "{Storage Account Name, to save checpoints for Event Hub}";
            string storageAccountKey         = "Storage Account Key";
            string eventProcessorHostName    = "myprocessor";



            string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", storageAccountName, storageAccountKey);


            EventProcessorHost eventProcessorHost = new EventProcessorHost(eventProcessorHostName,
                                                                           eventHubName,
                                                                           eventHubConsumerGroupName,
                                                                           eventHubConnectionString,
                                                                           storageConnectionString);

            Console.WriteLine("Registering Executer EventProcessor...");

            var options = new EventProcessorOptions();

            options.InitialOffsetProvider = (pId) => DateTime.UtcNow;
            options.ExceptionReceived    += (sender, e) => { Console.WriteLine(e.Exception); };
            eventProcessorHost.RegisterEventProcessorAsync <RuleExecuterEventProcessor>(options).Wait();

            Console.WriteLine("Receiving. Press enter key to stop the Executer and stop the app.");
            Console.ReadLine();

            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #59
0
        private static void Main()
        {
            var eventHubConnectionString = ConfigurationManager.AppSettings["eventHubConnectionString"];
            var eventHubName             = ConfigurationManager.AppSettings["sourceEventHubName"];
            var storageAccountName       = ConfigurationManager.AppSettings["storageAccountName"];
            var storageAccountKey        = ConfigurationManager.AppSettings["storageAccountKey"];

            var storageConnectionString =
                $"DefaultEndpointsProtocol=https;AccountName={storageAccountName};AccountKey={storageAccountKey}";

            var eventProcessorHostName = Guid.NewGuid().ToString();
            var eventProcessorHost     = new EventProcessorHost(eventProcessorHostName, eventHubName,
                                                                EventHubConsumerGroup.DefaultGroupName, eventHubConnectionString, storageConnectionString);

            var eventHubConfig = new EventHubConfiguration();

            eventHubConfig.AddEventProcessorHost(eventHubName, eventProcessorHost);

            var config = new JobHostConfiguration(storageConnectionString);

            config.UseEventHub(eventHubConfig);

            Console.WriteLine("Registering EventProcessor...");

            var options = new EventProcessorOptions();

            options.ExceptionReceived += (sender, e) =>
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Exception);
                Console.ResetColor();
            };

            eventProcessorHost.RegisterEventProcessorAsync <MessageProcessor>(options);

            var host = new JobHost(config);

            host.RunAndBlock();

            eventProcessorHost.UnregisterEventProcessorAsync().Wait();
        }
예제 #60
0
        public override bool OnStart()
        {
            ServicePointManager.DefaultConnectionLimit = 12;

            var hostName = CloudConfigurationManager.GetSetting("ehHostName");
            var connectionString = CloudConfigurationManager.GetSetting("ehConnectionString");
            var hubName = CloudConfigurationManager.GetSetting("ehName");
            var storageConnectionString = CloudConfigurationManager.GetSetting("storageConnectionString");

            _host = new EventProcessorHost(hostName, hubName, EventHubConsumerGroup.DefaultGroupName, connectionString, storageConnectionString);

            _host.PartitionManagerOptions = new PartitionManagerOptions
            {
                MaxReceiveClients = 1    // easy to debug... bad for scalability  :-)
            };

            _host.RegisterEventProcessorAsync<MyEventProcessor>().Wait();

            Trace.TraceInformation("NTM.InventoryManagement has been started");

            return base.OnStart();
        }