Example #1
0
        /// <summary>
        /// Send the responses back to the client
        /// </summary>
        /// <param name="sc">The responses (one to many)</param>
        /// <param name="replyToId">The identifier of the object to reply to</param>
        /// <param name="srcId">Source Unit Id</param>
        private void SendResponsesBack(StringCollection sc, string replyToId, string srcId)
        {
            MessageProcessor respProc = MessageProcessorManager.GetProcessor(replyToId);

            if (respProc != null)
            {
                foreach (string s in sc)
                {
                    respProc.OneWaySend(s);
                }
            }
        }
        public MessageTermination(Bootstrap bootstrap, ISystemController systemController)
        {
            MessageOperationManager.Builder operationBuilder = new MessageOperationManager.Builder();
            operationBuilder.WithMessageQueueOut(bootstrap.GetMessageQueueFromVariableSet(TERMINATION));

            MessageProcessorManager messageProcessorManager = MessageProcessorManager.Builder.NewBuilder()
                                                              .WithSystemController(systemController)
                                                              .WithHeartbeatCache(bootstrap.GetCachedFromVariableSet(HEARTBEAT_CACHE))
                                                              .WithOutMessageQueue(bootstrap.GetMessageQueueFromVariableSet(TERMINATION))
                                                              .Build();

            operationBuilder.WithProcessManager(messageProcessorManager);

            manager = operationBuilder.Build();
        }
        public void Process(string body)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(body);
            switch (doc.DocumentElement.Name)
            {
            case "s1":
                string uri = doc.DocumentElement.ChildNodes[0].InnerXml;
                MessageProcessorManager.CloseProcessor(uri);
                BecsEngine.MainEngine.CommObjects.ChannelManager.CloseChannel(uri);
                break;

            default:
                break;
            }
        }
        private void OnInQueueReceiveCompleted(FecsBecsHeader header, string body)
        {
            if (_channelMgr != null)
            {
                string   uri     = header.ID;
                IChannel channel = _channelMgr.GetChannel(uri);
                if (channel == null)
                {
                    channel = _channelMgr.OpenChannel(uri, ChannelType.BecsQueue);
                    if (channel != null)
                    {
                        MessageProcessorManager.OnNewConnection(channel);
                    }
                }
                if (channel != null)
                {
                    BecsChannel   bc     = (BecsChannel)channel;
                    StringBuilder packet = new StringBuilder(256);
                    packet.AppendFormat(null, "<{0} {1}=\"{2}\" {3}=\"{4}\">{5}</{0}>",
                                        Tags.Packet, Tags.PacketSrcAttr, header.PacketInfo.SourceId,
                                        Tags.PacketDateAttr, Dtx.DtxToString(header.PacketInfo.Dtx), body);
                    string  xml         = packet.ToString();
                    ILogger localLogger = null;
                    try
                    {
                        Database   d        = null;
                        CmpUnitsDB cmpUnits = new CmpUnitsDB();
                        //d = DatabaseFactory.GetDatabase();
                        localLogger = DatabaseFactory.Logger;

                        if (localLogger != null)
                        {
                            localLogger.AddLog("[OnInQueueReceiveCompleted]: Updating ID: " + header.PacketInfo.SourceId + " IP :" + header.IP, LoggerSeverities.Debug);
                        }
                        if (Convert.ToInt32(header.PacketInfo.SourceId) != -1)
                        {
                            if (cmpUnits.UpdateIP(Convert.ToInt32(header.PacketInfo.SourceId), header.IP) != 1)
                            {
                                if (localLogger != null)
                                {
                                    localLogger.AddLog("[OnInQueueReceiveCompleted]: Error Updating IP", LoggerSeverities.Debug);
                                }
                            }
                            else
                            {
                                if (localLogger != null)
                                {
                                    localLogger.AddLog("[OnInQueueReceiveCompleted]: Update OK", LoggerSeverities.Debug);
                                }
                            }
                        }
                    }
                    catch
                    {
                        // Do not do nothing??
                        // Si tenemos un error en realizar un update de la ip
                        // no hacemos nada
                        if (localLogger != null)
                        {
                            localLogger.AddLog("[OnInQueueReceiveCompleted]: Error Updating IP", LoggerSeverities.Debug);
                        }
                    }
                    Interlocked.Increment(ref _packetId);
                    OPSTelegrama opsTel = OPSTelegramaFactory.CreateOPSTelegrama(_packetId, xml);
                    bc.ReceiveMessage(opsTel);
                }
            }
        }
 public void WithProcessManager(MessageProcessorManager messageProcessorManager)
 {
     this.MessageProcessorManager = messageProcessorManager;
 }