Exemple #1
0
        private void procHttpQueueLNG()
        {
            long lstEvent = 0;

            logger.Info("Inicializando thread do processamento da fila de eventos de Livro de Negocios Streamer");
            while (bKeepRunning)
            {
                try
                {
                    EventoHttpLivroNegocios e;
                    if (queueHttpLNG.TryDequeue(out e))
                    {
                        if (OnEventoHttpLivroNegocios != null)
                        {
                            HttpLivroNegociosEventArgs args = new HttpLivroNegociosEventArgs();
                            args.Evento = e;
                            OnEventoHttpLivroNegocios(this, args);
                        }

                        if (MDSUtils.shouldLog(lstEvent))
                        {
                            lstEvent = DateTime.UtcNow.Ticks;
                            logger.Info("Fila queueHttpLNG: " + queueHttpLNG.Count + " eventos.");
                        }

                        continue;
                    }

                    lock (syncQueueHttpLNG)
                    {
                        Monitor.Wait(syncQueueHttpLNG, QUEUE_WAIT_TIMEOUT);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("procHttpQueueLNG: " + ex.Message, ex);
                }
            }
        }
        private void despacharEventos(object sender, HttpLivroNegociosEventArgs args)
        {
            try
            {
                string mensagem = null;

                EventoHttpLivroNegocios httpLNG = args.Evento;

                if (dctSessions.ContainsKey(httpLNG.instrumento))
                {
                    mensagem = JsonConvert.SerializeObject(httpLNG);
                    mensagem = MDSUtils.montaMensagemHttp(ConstantesMDS.TIPO_REQUISICAO_LIVRO_NEGOCIOS, httpLNG.instrumento, null, mensagem);

                    if (!String.IsNullOrEmpty(mensagem))
                    {
                        queueToStreamer.Enqueue(mensagem);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("despacharEventos(): " + ex.Message, ex);
            }
        }