Example #1
0
        private void startMq(String ageintId)
        {
            RabbitConsumer.Connect(ageintId);
            RabbitConsumer.ConsumeMessagesStart(ageintId);

            bgAgentWorker = new BackgroundWorker();


            //ReportProgress메소드를 호출하기 위해서 반드시 true로 설정, false일 경우 ReportProgress메소드를 호출하면 exception 발생
            bgAgentWorker.WorkerReportsProgress = true;

            //스레드에서 취소 지원 여부
            bgAgentWorker.WorkerSupportsCancellation = true;

            //스레드가 run시에 호출되는 핸들러 등록
            bgAgentWorker.DoWork += new DoWorkEventHandler(bw_DoWork);


            // ReportProgress메소드 호출시 호출되는 핸들러 등록
            bgAgentWorker.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);


            // 스레드 완료(종료)시 호출되는 핸들러 동록
            bgAgentWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);

            bgAgentWorker.RunWorkerAsync();

            /* Mq 수신 시작 알림 */
            MqSendHealthVo msVo = new MqSendHealthVo();

            msVo.agent_id     = ageintId;
            msVo.agent_status = "IDLE";
            msVo.res_typ      = "RES";
            RabbitProducer.Connect();
            RabbitProducer.MqSendMessages(ageintId, msVo.toJson());
            RabbitProducer.Disconnect();
            logger.Info("agent_id : " + msVo.agent_id + " IDLE.. ");

            startAgent.Text  = "STOP";
            this.Visible     = false;
            trayIcon.Visible = true;
        }