Example #1
0
        /// <summary>
        /// 재시도 함수
        /// </summary>
        private void tryAgain()
        {
            libMyUtil.clsMSMQ            objMSMQ  = new libMyUtil.clsMSMQ();
            System.Diagnostics.Stopwatch objWatch = new System.Diagnostics.Stopwatch();

            int retryMsgCnt;
            int i;

            while (objMSMQ.canReadQueue(qPath_retry))
            {
                retryMsgCnt = objMSMQ.queueMsgCnt(this.qPath_retry);
                for (i = 0; i < retryMsgCnt; i++)
                {
                    libMyUtil.pageCallingInfo rcvObj = (libMyUtil.pageCallingInfo)objMSMQ.peekData(this.qPath_retry, this.objType, this.rcvTimeOut);
                    if ((System.DateTime.Now - rcvObj.lastTry).Duration().TotalMilliseconds < this.retryInterval)
                    {
                        break;
                    }
                    prcRcvObject(objMSMQ.receiveData(this.qPath_retry, this.objType, this.rcvTimeOut));
                }

                System.Threading.Thread.Sleep(this.retryInterval);
            }

            libMyUtil.clsThread.SetLabel(RetryCallerState, "오류");
            MessageBox.Show(string.Format("해당큐({0})에 접근할 수 없습니다.", qPath_retry));
        }
Example #2
0
        /// <summary>
        /// 메인 함수
        /// </summary>
        private void RunCaller()
        {
            libMyUtil.clsMSMQ objMSMQ = new libMyUtil.clsMSMQ();

            while (objMSMQ.canReadQueue(qPath))
            {
                prcRcvObject(objMSMQ.receiveData(this.qPath, this.objType, this.rcvTimeOut));
            }

            libMyUtil.clsThread.SetLabel(MainCallerState, "오류");
            MessageBox.Show(string.Format("해당큐({0})에 접근할 수 없습니다.", qPath));
        }
Example #3
0
        private void runTest()
        {
            libMyUtil.clsMSMQ objMSMQ = new libMyUtil.clsMSMQ();
            long sendData             = 0;

            if (objMSMQ.canReadQueue(qPath))
            {
                while (start)
                {
                    objMSMQ.sendData(qPath, sendData);
                    sendData++;
                }
            }
            else
            {
                MessageBox.Show("접근 불가");
            }
        }
Example #4
0
 private void runTest()
 {
     libMyUtil.clsMSMQ objMSMQ = new libMyUtil.clsMSMQ();
     if (objMSMQ.canReadQueue(qPath))
     {
         while (start)
         {
             object rcvData = objMSMQ.receiveData(qPath, new Type[] { typeof(long) }, 5);
             if (rcvData != null)
             {
                 long rcvNum = (long)rcvData;
                 objUtil.writeLog(rcvNum.ToString());
             }
         }
     }
     else
     {
         MessageBox.Show("접근 불가");
     }
 }
Example #5
0
        /// <summary>
        /// 수신된 메시지 처리, null수신시 sleep
        /// </summary>
        private void prcRcvObject(object rcvObj)
        {
            if (rcvObj != null)
            {
                System.Diagnostics.Stopwatch objWatch = new System.Diagnostics.Stopwatch();
                objWatch.Start();

                libMyUtil.clsMSMQ         objMSMQ     = new libMyUtil.clsMSMQ();
                libMyUtil.pageCallingInfo callingInfo = (libMyUtil.pageCallingInfo)rcvObj;

                string Result;
                string url      = callingInfo.url;
                string postData = callingInfo.postData;
                int    timeOut  = callingInfo.timeOut;

                if (callingInfo.httpMethod.Equals("POST"))
                {
                    Result = libMyUtil.clsWeb.SendPostData(postData, url, this.encodeType, timeOut * 1000);
                }
                else if (callingInfo.httpMethod.Equals("GET"))
                {
                    Result = libMyUtil.clsWeb.SendQueryString(postData, url, timeOut * 1000);
                }
                else
                {
                    Result = "UNKNOWN HTTP METHOD";
                }

                objUtil.writeLog(string.Format("CALL RESULT : {0}\r\nFKEY:{1}\r\nURL:{2}", Result, callingInfo.FKEY, callingInfo.url));

                if (Result.Equals(callingInfo.callresult))
                {
                    UpdateResult(callingInfo, Result);//성공 결과 DB에 저장
                }
                else if (Result.Equals("FAIL"))
                {
                    //재시도
                    callingInfo.failCnt++;                            //실패 카운트 증가
                    callingInfo.lastTry = System.DateTime.Now;        //시간 기록
                    if (callingInfo.failCnt < this.MaxCallingFailCnt) //설정한 횟수만큼 재시도
                    {
                        objMSMQ.sendData(qPath_retry, callingInfo);   //재시도 큐에 저장
                    }
                    else
                    {
                        callingInfo.writeLog(Result);      //최종 실패 메시지 로그 기록
                        UpdateResult(callingInfo, Result); //실패 결과 DB에 저장
                    }
                }
                else
                {
                    callingInfo.writeLog(Result);      //최종 실패 메시지 로그 기록
                    UpdateResult(callingInfo, Result); //실패 결과 DB에 저장
                }

                objWatch.Stop();
                if (System.DateTime.Now.Millisecond > 500)
                {
                    objUtil.writeLog(string.Format("TIME SPAN : {0} millisecond", objWatch.Elapsed.TotalMilliseconds.ToString()));
                }
            }
            else
            {
                System.Threading.Thread.Sleep(this.sleep);//큐에 메시지 없으면 슬립
            }
        }