示例#1
0
        /// <summary>
        /// Handler for AssistentQueue
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _activeMqConnector_Message(object sender, BreanosConnectors.Interface.OnMessageEventArgs e)
        {
            logger.Trace();
            if (e == null)
            {
                logger.Error($"Received null message from ActiveMq");
                return;
            }
            if (e.Properties == null)
            {
                logger.Error($"Received message with null properties from ActiveMq");
            }
            if (!e.Properties.ContainsKey("ContentType"))
            {
                logger.Error($"Received a message from amq but did not contain ContentType");
                return;
            }
            logger.Trace($"Message from the AMQ: ContentType: {e.Properties["ContentType"]}; Content: {e.Content}");

            switch (e.Properties["ContentType"])
            {
            case BrokerCommands.KPU_REGISTRATION:
                var isUnpackSuccessful = BreanosConnectors.SerializationHelper.TryUnpack(e.Content, out KpuRegistrationRequest registrationRequest);
                if (isUnpackSuccessful)
                {
                    IncomingKpuRegistration(registrationRequest);
                    SendKpuRegistrationRequestToSecurityService(registrationRequest);
                }
                else
                {
                    logger.Warn($"Could not unpack KpuRegistrationRequest");
                }
                break;

            case BrokerCommands.MODEL_UPDATE:
                var IsUpdate = BreanosConnectors.SerializationHelper.TryUnpack(e.Content, out ModelUpdate[] updates);
                if (IsUpdate)
                {
                    UpdateModelValue(updates);
                }
                else
                {
                    logger.Error($"Could not unpack modelupdate from kpu");
                }
                break;

            case BrokerCommands.PACKAGE:
                var packageKpuId = (string)e.Properties["KpuId"];
                if (_currentKpuPackageRequests.ContainsKey(packageKpuId) && _currentKpuPackageRequests[packageKpuId].Count > 0)
                {
                    foreach (var connection in _currentKpuPackageRequests[packageKpuId])
                    {
                        SendKpuPackage(connection, packageKpuId, e.Content);
                    }
                    _currentKpuPackageRequests[packageKpuId].Clear();
                }
                break;

            case BrokerCommands.REQUESTKPUID:
                logger.Error($"BrokerCommands.REQUESTKPUID has been called. Please hold the line!");
                HandleRequestKPUIdRequest(e.Content);
                break;

            default:
                break;
            }
        }
示例#2
0
 private void Connector_Message(object sender, BreanosConnectors.Interface.OnMessageEventArgs e)
 {
     throw new NotImplementedException();
 }