Exemple #1
0
        private string SendReplayJobRequestToMq(JobForMq job)
        {
            using (MessageQueue outQ = MqHelper.GetQ(OUTPUT_Q_PATH, QueueAccessMode.Send, null, null))
            {
                FJobRequest fJobRequest = FJobRequest.CreateReplayRequest(job.JobId);
                Message     m           = new Message(fJobRequest);
                outQ.Send(m);

                return(m.Id);
            }
        }
Exemple #2
0
        private string SendJobToMq(FJobRequest fJobRequest)
        {
            using (MessageQueue outQ = MqHelper.GetQ(OUTPUT_Q_PATH, QueueAccessMode.Send, null, null))
            {
                Debug.WriteLine($"Sending request with JobId {fJobRequest.JobId} to output Q.");

                Message m = new Message(fJobRequest);
                outQ.Send(m);

                return(m.Id);
            }
        }
Exemple #3
0
        private MessageQueue GetJobResponseQueue()
        {
            Type[] rTtypes = new Type[] { typeof(FCoordsResult) };

            MessagePropertyFilter mpf = new MessagePropertyFilter
            {
                Body = true,
                //Id = true,
                CorrelationId = true
            };

            MessageQueue result = MqHelper.GetQ(INPUT_COORDS_Q_PATH, QueueAccessMode.Receive, rTtypes, mpf);

            return(result);
        }
Exemple #4
0
        private MessageQueue GetJobResponseQueue()
        {
            Type[] rTtypes = new Type[] { typeof(FJobResult) };

            MessagePropertyFilter mpf = new MessagePropertyFilter
            {
                Body = true,
                //Id = true,
                CorrelationId = true
            };

            MessageQueue result = MqHelper.GetQ(_inputQueuePath, QueueAccessMode.Receive, rTtypes, mpf);

            return(result);
        }
Exemple #5
0
        private void RemoveResponses(string correlationId)
        {
            if (correlationId == null)
            {
                Debug.WriteLine("Attempting to remove responses with a null cor id. Not removing any responses.");
                return;
            }

            using (MessageQueue inQ = GetJobResponseQueue())
            {
                Message m = null;
                do
                {
                    m = MqHelper.GetMessageByCorId(inQ, correlationId, TimeSpan.FromMilliseconds(10));
                }while (m != null);
            }
        }
Exemple #6
0
        private FHistorgram GetResponseFromMq(string requestMsgId)
        {
            using (MessageQueue inQ = GetJobResponseQueue())
            {
                Message m = MqHelper.GetMessageByCorId(inQ, requestMsgId, WaitDuration);

                if (m == null)
                {
                    Debug.WriteLine("The FHistogram did not arrive.");
                    return(null);
                }

                Debug.WriteLine("Received a message.");
                FHistorgram result = (FHistorgram)m.Body;

                return(result);
            }
        }
Exemple #7
0
        private async Task ReceiveImageResultsAsync()
        {
            using (MessageQueue inQ = GetJobResponseQueue())
            {
                while (!_cts.IsCancellationRequested /*&& !jobForMq.IsLastSubJob*/)
                {
                    Message m = await MqHelper.ReceiveMessageByCorrelationIdAsync(inQ, _jobForMq.MqRequestCorrelationId, _waitDuration);

                    if (m == null)
                    {
                        Debug.WriteLine($"No FGenResult message present for correlationId: {FMsgId(_jobForMq.MqRequestCorrelationId)}.");
                        continue;
                    }

                    FJobResult jobResult = (FJobResult)m.Body;
                    PointInt   pos       = jobResult.Area.Point;
                    Debug.WriteLine($"Received FJobResult for correlationId: {FMsgId(_jobForMq.MqRequestCorrelationId)}, X:{pos.X}, Y:{pos.Y}.");

                    SubJob subJob = CreateSubJob(jobResult, _jobForMq);

                    _sendQueue.Add(subJob);
                }

                if (_jobForMq.IsLastSubJob)
                {
                    Debug.WriteLine($"The result listener for {_jobForMq.JobId} is stopping. We have received the last result.");
                }
                else if (_cts.IsCancellationRequested)
                {
                    Debug.WriteLine($"The result listener for {_jobForMq.JobId} has been cancelled.");
                }
                else
                {
                    Debug.WriteLine($"The result listener for {_jobForMq.JobId} is stopping for unknown reason.");
                }
            }
        }
Exemple #8
0
        private SCoords GetResponseFromMq(string requestMsgId)
        {
            using (MessageQueue inQ = GetJobResponseQueue())
            {
                Message m = MqHelper.GetMessageByCorId(inQ, requestMsgId, WaitDuration);

                if (m == null)
                {
                    Debug.WriteLine("The FCoordsResult did not arrive.");
                    return(null);
                }

                Debug.WriteLine("Received a message.");
                FCoordsResult jobResult = (FCoordsResult)m.Body;

                MqMessages.Coords coords = jobResult.Coords;

                SPoint  leftBot  = new SPoint(coords.StartX, coords.StartY);
                SPoint  rightTop = new SPoint(coords.EndX, coords.EndY);
                SCoords result   = new SCoords(leftBot, rightTop);

                return(result);
            }
        }