private void despacharEventos(object sender, HttpNegocioEventArgs args)
        {
            try
            {
                string            mensagem = null;
                EventoHttpNegocio httpNEG  = args.Evento;


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

                    logger.Debug("INCR Negocio[" + httpNEG.instrumento + "]: " + mensagem);

                    if (!String.IsNullOrEmpty(mensagem))
                    {
                        queueToStreamer.Enqueue(mensagem);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("despacharEventos(): " + ex.Message, ex);
            }
        }
        protected override void trataAssinatura(string tipo, string instrumento, string sessionID)
        {
            string mensagem = "";
            NegociosConsumerBase negociosConsumer = ContainerManager.Instance.NegociosConsumer;

            logger.DebugFormat("{0} assinatura de {1} de {2}", sessionID, tipo, instrumento);

            EventoHttpNegocio httpNEG = negociosConsumer.SnapshotStreamerNegocio(instrumento);

            if (httpNEG != null)
            {
                Dictionary <string, string> cabecalho = MDSUtils.montaCabecalhoStreamer(tipo, null, ConstantesMDS.HTTP_OFERTAS_TIPO_ACAO_COMPLETO, instrumento, negociosConsumer.RetornaCasasDecimais(instrumento), sessionID);

                httpNEG.cabecalho = cabecalho;

                mensagem = JsonConvert.SerializeObject(httpNEG);
                mensagem = MDSUtils.montaMensagemHttp(ConstantesMDS.TIPO_REQUISICAO_NEGOCIOS, instrumento, null, mensagem);

                logger.Debug("SNAP Negocio[" + httpNEG.instrumento + "]: " + mensagem);

                bool sinaliza = queueToStreamer.IsEmpty;
                queueToStreamer.Enqueue(mensagem);

                if (sinaliza)
                {
                    lock (syncQueueToStreamer)
                    {
                        Monitor.Pulse(syncQueueToStreamer);
                    }
                }
            }
        }
예제 #3
0
 public void SendEvent(EventoHttpNegocio e)
 {
     try
     {
         //bool bsinaliza = queueHttpNEG.IsEmpty;
         queueHttpNEG.Enqueue(e);
         //if (bsinaliza)
         //{
         //    lock (syncQueueHttpNEG)
         //    {
         //        Monitor.Pulse(syncQueueHttpNEG);
         //    }
         //}
     }
     catch (Exception ex)
     {
         logger.Error("SendEvent(EventoHttpNegocio): " + ex.Message, ex);
     }
 }