public override void Run()
        {
            // This is a sample worker implementation. Replace with your logic.
            Trace.TraceInformation("TestRequestSubmitter entry point called", "Information");

            var    tps = int.Parse(CloudConfigurationManager.GetSetting("TPS"));
            var    totalTransactions       = int.Parse(CloudConfigurationManager.GetSetting("TotalTransactions"));
            string instanceId              = RoleEnvironment.CurrentRoleInstance.Id;
            string storageConnectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");
            var    serviceUri              = new Uri(CloudConfigurationManager.GetSetting("ServiceUri"));

            Task webApiSubmitterTask = TestWebApiSubmitter.StartRequestSubmitterAsync(serviceUri, storageConnectionString, instanceId + "-WebApi", tps,
                                                                                      totalTransactions);

            string requestQueueName  = CloudConfigurationManager.GetSetting("ServiceRequestQueue");
            string responseQueueName = "response-queue-" + instanceId.ToLowerInvariant().Replace('_', '-');

            Task queueSubmitterTask = TestServiceQueueSubmitter.StartRequestSubmitterAsync(storageConnectionString, requestQueueName, responseQueueName, tps, totalTransactions);

            try
            {
                Task.WhenAny(queueSubmitterTask, webApiSubmitterTask).Wait();
            }
            catch (Exception exception)
            {
                TestRecorder.LogException(storageConnectionString, instanceId, exception);
                throw;
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
#if DEBUG
            var listeners = new TraceListener[] { new TextWriterTraceListener(Console.Out) };
            Debug.Listeners.AddRange(listeners);
#endif

            SetupConnections();

            const int tps = 5;
            const int totalTransactions       = 50;
            string    requestQueueName        = CloudConfigurationManager.GetSetting("ServiceRequestQueue");
            string    instanceId              = Environment.MachineName;
            string    responseQueueName       = "response-queue-" + instanceId.ToLowerInvariant().Replace('_', '-');
            string    storageConnectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");
            Task      queueSubmitterTask      = TestServiceQueueSubmitter.StartRequestSubmitterAsync(storageConnectionString, requestQueueName, responseQueueName, tps, totalTransactions);
            string    serviceUri              = CloudConfigurationManager.GetSetting("ServiceUri");
            var       uri = new Uri(serviceUri);
            Task      webApiSubmitterTask = TestWebApiSubmitter.StartRequestSubmitterAsync(uri, storageConnectionString, instanceId + "WebApi", tps, totalTransactions);

            Task.WhenAny(webApiSubmitterTask, queueSubmitterTask).Wait();
        }