Пример #1
0
        void IIngestedRepos.SaveTestData(InProcessFeedMsg msg)
        {
            TestDataEntity msgEntity  = null;
            string         moreExInfo = string.Empty;

            try
            {
                msgEntity = MakeTestDataEntity(msg);

                // TODO 5-23-15 Failsafe requires using Transient Fault application block and
                // maybe circuit breaker pattern on all requests for cloud services.  Wrap below
                // code in that stuff as an example.
                AzureStorageHelpers.AzTableStorageInsert(ConstantsNEnums.TestMessageTableName, msgEntity);
            }
            catch (StorageException ex)
            {
                if (ex.Message.Contains("409"))
                {
                    moreExInfo = "\n HTTP 409 error code: RowKey already exists in table on insert.";
                }
                string displayMsg = string.Format("\n{0}.SaveTestData():", m_ThisName);
                ConsoleNTraceHelpers.DisplayExToConsoleNTrace(displayMsg, ex);
                ConsoleNTraceHelpers.DisplayInfoToConsoleNTrace(moreExInfo);
                throw;
            }
            catch (Exception ex)
            {
                string displayMsg = string.Format("\n{0}.SaveTestData():", m_ThisName);
                ConsoleNTraceHelpers.DisplayExToConsoleNTrace(displayMsg, ex);
                throw;
            }
        }
        public static void Main(string[] args)
        {
            Console.Title = m_ThisName;
            Console.WriteLine("{0}.Main(): Press <ENTER> to enqueue one", m_ThisName);
            Console.WriteLine("  test message to SB queue '{0}' via WCF NetMessagingBinding",
                              ConstsNEnums.IngestionQueueName);
            InitSourceIds(args);

            while (true)
            {
                string userInput = ConsoleNTraceHelpers.PauseTillUserPressesEnterExitOnX();
                if (userInput.ToLower() == "x")
                {
                    break;
                }

                try
                {
                    // Assume the queue exists, having been previously provisioned in Azure Portal.
                    Console.WriteLine("{0}.Main(): Enqueueing test message..", m_ThisName);

                    TestMessage msg = MakeTestMessage(++m_MsgSeqNumber, m_SourceId, m_SourceGroupId);
                    IngestTestData(msg, ConstsNEnums.IngestionQueueEndpointName);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("{0}.Main(): IngestTestData() proxy threw exception\n {1}.", m_ThisName, ex);
                }
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            // Get rid of compiler warnings by using the GenericResolver related variables.
            m_SbMessage        = new TestMessage();
            m_InProcessFeedMsg = new InProcessFeedMsg();

            Console.Title = m_ThisName;
            Console.WriteLine("{0}.Main(): Entered. Awaiting your input to start the", m_ThisName);
            Console.WriteLine("  QueuedServicsBusHost for the Service Bus queue '{0}'\n  via WCF NetMessagingBinding.",
                              ConstantsNEnums.IngestionQueueName);
            ConsoleNTraceHelpers.PauseTillUserPressesEnter();
            QueuedServiceBusHost queuedHost = null;

            try
            {
                Uri sbBaseAddr = new Uri("sb://AzExploreSbNS.servicebus.windows.net/");
                queuedHost = new QueuedServiceBusHost(typeof(DataFeedManager), false, sbBaseAddr);
                queuedHost.Open();
                Console.WriteLine("{0}.Main():  QueuedServiceBusHost opened OK.  Working.....", m_ThisName);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}.Main():  host.Open() Threw exception!\n     {1}", m_ThisName, ex);
            }

            Console.WriteLine("\n{0}.Main():  Press ENTER to EXIT.", m_ThisName);
            Console.ReadLine();
            CloseOrAbortHosts(queuedHost);
            Console.WriteLine("\n{0}.Main(): Exiting......", m_ThisName);
        }
Пример #4
0
        static void Main(string[] args)
        {
            Console.Title = m_ThisName;
            Console.WriteLine("{0}.Main(): Entered. Awaiting your input to start the", m_ThisName);
            Console.WriteLine("  QueuedServicsBusHost for the Service Bus queue '{0}'\n  via WCF NetMessagingBinding.",
                              ConstsNEnums.IngestionQueueName);
            ConsoleNTraceHelpers.PauseTillUserPressesEnter();
            QueuedServiceBusHost host = null;

            try
            {
                host = new QueuedServiceBusHost(typeof(DataFeedsManager.DataFeedsManager));
                host.Open();
                Console.WriteLine("{0}.Main():  QueuedServiceBusHost opened OK.  Working.....", m_ThisName);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}.Main():  host.Open() Threw exception!\n     {1}", m_ThisName, ex.ToString());
            }

            Console.WriteLine("\n{0}.Main():  Press ENTER to EXIT.", m_ThisName);
            Console.ReadLine();
            if (host != null)
            {
                host.Close();
            }
            Console.WriteLine("\n{0}.Main(): Exiting......", m_ThisName);
        }
Пример #5
0
        static void Main(string[] args)
        {
            try
            {
                m_StorageAcct = GetCloudStorageAccount();
                //CloudTable table = ObtainTableCreatIfNotExist("customers");
                CloudTable table = ObtainTableCreatIfNotExist("orders");

                OrderEntity newOrder = new OrderEntity("George", "20150502");
                newOrder.OrderNumber  = "1";
                newOrder.ShippedDate  = Convert.ToDateTime("5/2/2015");
                newOrder.RequiredDate = Convert.ToDateTime("5/10/2015");
                newOrder.Status       = "shipped";
                TableOperation insertOperation = TableOperation.Insert(newOrder);
                table.Execute(insertOperation);
            }
            catch (StorageException ex)
            {
                if (ex.Message.Contains("409"))
                {
                    Console.WriteLine("Caught exception:\n   Likely RowKey already exists on insert.\n  ex = {0}", ex);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Caught exception:  ex = {0}", ex);
            }
            ConsoleNTraceHelpers.PauseTillUserPressesEnterExitOnX();
        }
Пример #6
0
        static void Main(string[] args)
        {
            // Get rid of compiler warnings by using the GenericResolver related variables.
            m_FeedStats          = new DataFeedStatistics();
            m_DataAnalysisResult = new IngestedDataAnalysisResult();

            Console.Title = m_ThisName;
            Console.WriteLine("{0}.Main(): Entered. Awaiting your input to start the", m_ThisName);
            Console.WriteLine("Service Host for the AdminManager and SomeManager");
            ConsoleNTraceHelpers.PauseTillUserPressesEnter();

            ServiceHost <AdminManager> adminHost       = null;
            ServiceHost <SomeManager>  someManagerHost = null;

            try
            {
                adminHost = new ServiceHost <AdminManager>();
                adminHost.Open();
                Console.WriteLine("{0}.Main():  Admin ServiceHost opened OK.", m_ThisName);

                someManagerHost = new ServiceHost <SomeManager>();
                someManagerHost.Open();
                Console.WriteLine("{0}.Main():  SomeManager ServiceHost opened OK.", m_ThisName);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}.Main():  host.Open() Threw exception!\n     {1}", m_ThisName, ex);
            }
            Console.WriteLine("\n{0}.Main():  Press ENTER to EXIT.", m_ThisName);
            Console.ReadLine();
            CloseOrAbortHosts(adminHost, someManagerHost);
            Console.WriteLine("\n{0}.Main(): Exiting......", m_ThisName);
        }
 void IAdminValidityEngine.IsPresentFeedComponentInfoRequestValid(string componentName)
 {
     // In a real app one would likely have the FeedAdminDA check to see if the componentName
     // was an active Feed Component in the system and throw an exception if not.
     // That's too much work for a demo.  This suffices to show the concept and test it.
     if (string.IsNullOrEmpty(componentName))
     {
         ConsoleNTraceHelpers.DisplayInfoToConsoleNTrace(m_ThisName + ".IAdminValidityEngine.IsPresentFeedComponentInfoRequestValid():  arg was null or empty.");
         throw new ArgumentNullException("componentName", "IAdminValidityEngine -- String was null or empty.");
     }
 }
Пример #8
0
        void IDataFeeds.IngestTestData(TestMessage msg)
        {
            string greeting = String.Format("\n{0}.IngestTestData(): Entered.", m_ThisName);

            Console.WriteLine(greeting);
            Trace.TraceInformation("**" + greeting);
            ConsoleNTraceHelpers.DisplayTestMessage(msg);
            ConsoleNTraceHelpers.TraceTestMessage(msg);

            // Below is where the code goes that does the work of this service operation.
            // That code will be developed in subsequent iterations.
        }
 long IFeedAdminRepos.GetQueueLength(string queueName)
 {
     try
     {
         QueueDescription queueDescr = iFX.Azure.AzureServiceBusHelpers.GetQueueDescription(queueName);
         long             count      = queueDescr.MessageCount;
         return(count);
     }
     catch (Exception ex)
     {
         ConsoleNTraceHelpers.DisplayExToConsoleNTrace(m_ThisName + ".GetQueueLength()", ex);
         throw;
     }
 }
Пример #10
0
        private static void DisplayMsgAndQueueLength(TestMessage msg, InProcessFeedMsg checkedMsg)
        {
            // For test client only.
            IFeedAdminDA feedAdminDaProxy = InProcFactory.CreateInstance <AdminDA, IFeedAdminDA>();
            long         queueLength      = feedAdminDaProxy.GetQueueLength(iFX.Common.ConstantsNEnums.IngestionQueueName);

            InProcFactory.CloseProxy(feedAdminDaProxy);
            checkedMsg.QueueLength = queueLength;
            string queueLengthMsg = string.Format("{0} count = {1}",
                                                  iFX.Common.ConstantsNEnums.IngestionQueueName,
                                                  queueLength);

            ConsoleNTraceHelpers.DisplayInfoToConsoleNTrace(queueLengthMsg);
            ConsoleNTraceHelpers.DisplayTestMessage(msg);
            ConsoleNTraceHelpers.TraceTestMessage(msg);
        }
Пример #11
0
        private static IngestedDataAnalysisResult AnalyzeIngestedData()
        {
            IngestedDataAnalysisResult result = null;
            SomeDataAnalysisClient     proxy  = new SomeDataAnalysisClient("someDataAnalysis");

            try
            {
                result = proxy.AnalyzeIngestedData();
                proxy.Close();
            }
            catch (Exception ex)
            {
                ConsoleNTraceHelpers.DisplayExToConsoleNTrace(m_ThisName + ".AnalyzeIngestedData(): Exception!! ", ex);
                proxy.Abort();
            }
            return(result);
        }
Пример #12
0
        private static DataFeedStatistics PresentQueueStatistics(string queueName)
        {
            DataFeedStatistics stats = null;
            FeedAdminClient    proxy = new FeedAdminClient("feedAdmin");

            try
            {
                stats = proxy.PresentFeedComponentInfo(queueName);
                proxy.Close();
            }
            catch (Exception ex)
            {
                ConsoleNTraceHelpers.DisplayExToConsoleNTrace(m_ThisName + ".PresentQueueStatistics(): Exception!! ", ex);
                proxy.Abort();
            }
            return(stats);
        }
 DataFeedStatistics IFeedAdminRepos.GetFeedStatistics(string queueName)
 {
     try
     {
         DataFeedStatistics stats = new DataFeedStatistics();
         stats.FeedComponentName       = queueName;
         stats.StatsCollectionDateTime = DateTime.Now;
         QueueDescription queueDescr = iFX.Azure.AzureServiceBusHelpers.GetQueueDescription(queueName);
         stats.QueueLength           = queueDescr.MessageCount;
         stats.DeadLetterQueueLength = queueDescr.MessageCountDetails.DeadLetterMessageCount;
         return(stats);
     }
     catch (Exception ex)
     {
         ConsoleNTraceHelpers.DisplayExToConsoleNTrace(m_ThisName + ".GetFeedStatistics()", ex);
         throw;
     }
 }
Пример #14
0
        private static void IngestTestData(TestMessage msg, string queueName)
        {
            // "Programming WCF Services" 3rd edition by Juval Lowy pp 259-260 recommends the
            // following form when needing to catch exceptions near the SendQueuedTestMessage().
            DataFeedsClient proxy = new DataFeedsClient(queueName);

            try
            {
                proxy.IngestTestData(msg);
                proxy.Close();
                Console.WriteLine("{0}.IngestTestData(): Test message enqueued Ok.", m_ThisName);
                ConsoleNTraceHelpers.DisplayTestMessage(msg);
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0}.IngestTestData(): Proxy threw exception\n {1}.", m_ThisName, ex);
                proxy.Abort();
            }
        }
        DataFeedStatistics IFeedAdmin.PresentFeedComponentInfo(string componentName)
        {
            ConsoleNTraceHelpers.DisplayInfoToConsoleNTrace(m_ThisName + ".PresentFeedComponentInfo(): Entered:");

            // Check validity of all requests.
            IAdminValidityEngine validityEngProxy = InProcFactory.CreateInstance <ValidityEngine, IAdminValidityEngine>();

            validityEngProxy.IsPresentFeedComponentInfoRequestValid(componentName);
            InProcFactory.CloseProxy(validityEngProxy);

            // Retrieve Feed Component info
            DataFeedStatistics stats            = null;
            IFeedAdminDA       feedAdminDaProxy = InProcFactory.CreateInstance <AdminDA, IFeedAdminDA>();

            stats = feedAdminDaProxy.GetFeedStatistics(componentName);
            InProcFactory.CloseProxy(feedAdminDaProxy);

            return(stats);
        }
Пример #16
0
        private static void IngestTestData(TestMessage msg, string queueName)
        {
            // Allow calculation of elapsed time: From proxy instantiation
            // till the message is received by the instantiated service instance.
            msg.MessageSendDateTime = DateTime.Now;

            // "Programming WCF Services" 3rd edition by Juval Lowy pp 259-260 recommends the
            // following form when needing to catch exceptions near the SendQueuedTestMessage().
            DataFeedsClient proxy = new DataFeedsClient(queueName);

            try
            {
                proxy.IngestTestData(msg);
                proxy.Close();
                Console.WriteLine("{0}.IngestTestData(): Test message enqueued Ok.", m_ThisName);
                ConsoleNTraceHelpers.DisplayTestMessage(msg);
            }
            catch (Exception ex)
            {
                ConsoleNTraceHelpers.DisplayExToConsoleNTrace(m_ThisName + ".IngestTestData(): ", ex);
                proxy.Abort();
            }
        }