예제 #1
0
        private static ServiceHost createMicroserviceHost(IOrchestrationServiceInstanceStore instanceStore)
        {
            ServiceBusOrchestrationService orchestrationServiceAndClient =
                new ServiceBusOrchestrationService(ServiceBusConnectionString, "UnitTestTmp", instanceStore, null, null);

            //instanceStore.PurgeOrchestrationHistoryEventsAsync(DateTime.Now.AddYears(1), OrchestrationStateTimeRangeFilterType.OrchestrationCreatedTimeFilter).Wait();
            ServiceHost host = new ServiceHost(orchestrationServiceAndClient, orchestrationServiceAndClient, instanceStore, false);

            return(host);
        }
예제 #2
0
        /// <summary>
        /// Creates the instance of the host.
        /// </summary>
        /// <param name="orchestrationService"></param>
        /// <param name="orchestrationClient"></param>
        /// <param name="instanceStore"></param>
        /// <param name="resetHub"></param>
        /// <param name="loggerFactory"></param>
        /// <param name="scopes">List of scopes, which will be appended to logger scopes, every time</param>
        public ServiceHost(IOrchestrationService orchestrationService,
                           IOrchestrationServiceClient orchestrationClient,
                           IOrchestrationServiceInstanceStore instanceStore,
                           bool resetHub = false,
                           ILoggerFactory loggerFactory = null)
        {
            m_HubClient                 = new TaskHubClient(orchestrationClient);
            this.m_TaskHubWorker        = new TaskHubWorker(orchestrationService);
            this.m_InstanceStoreService = instanceStore;

            if (loggerFactory != null)
            {
                m_LoggerFactory = loggerFactory;
                m_Logger        = m_LoggerFactory.CreateLogger <ServiceHost>();
            }

            if (resetHub)
            {
                orchestrationService.DeleteAsync().Wait();
            }

            int n = 10;

            while (--n > 0)
            {
                try
                {
                    orchestrationService.CreateIfNotExistsAsync().Wait();
                    break;
                }
                catch (AggregateException aggEx)
                {
                    if (n <= 0)
                    {
                        throw;
                    }

                    if (aggEx.InnerException.Message.Contains("409"))
                    {
                        Thread.Sleep(10000);
                    }
                }
            }
        }
예제 #3
0
 /// <inheritdoc />
 public InstanceStoreBackedTrackingStore(IOrchestrationServiceInstanceStore instanceStore)
 {
     this.instanceStore = instanceStore;
 }