示例#1
0
        private async Task Initialize()
        {
            _presenterService          = ServiceProxy.Create <IPresenterService>(new Uri(_presenterServiceUri));
            _exComService              = ServiceProxy.Create <IExternalCommunicationService>(new Uri(_exComServiceUri));
            _securityService           = ServiceProxy.Create <ISecurityService>(new Uri(_securityServiceUri));
            _currentKpuPackageRequests = new Dictionary <string, List <string> >();
            logger.Trace($"Initializing Presenter service");
            _presenterService.Initialize().Wait();
            logger.Trace($"Initializing Presenter service complete");
            try
            {
                _configuration               = new ConfigurationBuilder().AddXmlFile("App.config").Build();
                _amqRoutes                   = new Dictionary <string, string>();
                _amqEndpoint                 = _configuration["Connection:Endpoint"];
                _amqUser                     = _configuration["Connection:User"];
                _amqPassword                 = _configuration["Connection:Password"];
                _amqRoutes["ToBlackboard"]   = _configuration["Routes:ToBlackboard"];
                _amqRoutes["FromBlackboard"] = _configuration["Routes:FromBlackboard"];
                await SetupActiveMq();
            }
            catch (Exception e)
            {
                logger.Error($"Exception while reading app.config and getting amq routes: {e.ToString()}");
                return;
            }

            try
            {
                var         proxy2  = ActorProxy.Create <IBlackboardActor>(new ActorId(42), "fabric:/Assistant");
                Task <bool> ret2    = proxy2.InitBlackboard();
                bool        retVal3 = ret2.Result;

                Task rett;
                rett = proxy2.StartProcessing();
            }
            catch (Exception e)
            {
                logger.Error(e.ToString());
            }
            logger.Trace($"Initializing Blackboard Actor complete");

            InitializeTransformerActor();


            var registerForMessagesAtBlackboardRequest = new RoutingRequest()
            {
                Id           = "Core",
                Path         = _amqRoutes["FromBlackboard"],
                ContentTypes = new string[]
                {
                    BrokerCommands.PACKAGE,
                    BrokerCommands.KPU_REGISTRATION,
                    BrokerCommands.MODEL_UPDATE
                },
            };
            var registerPackage = BreanosConnectors.SerializationHelper.Pack(registerForMessagesAtBlackboardRequest);
            await _activeMqConnector.SendAsync(registerPackage, _amqRoutes["ToBlackboard"], BrokerCommands.CONFIGURE_ROUTES);

            logger.Trace($"Registration with Blackboard complete.");
        }