protected override void trataAssinatura(string tipo, string instrumento, string sessionID) { string mensagem = ""; NegociosConsumerBase negociosConsumer = ContainerManager.Instance.NegociosConsumer; Dictionary <string, string> cabecalho = MDSUtils.montaCabecalhoStreamer(tipo, null, ConstantesMDS.HTTP_OFERTAS_TIPO_ACAO_COMPLETO, instrumento, negociosConsumer.RetornaCasasDecimais(instrumento), sessionID); logger.DebugFormat("{0} assinatura de {1} de {2}", sessionID, tipo, instrumento); // Aqui tem o pulo do gato // interrompe o processamento dos eventos ate a chegada do snapshot // para nao quebrar a sequencia do sinal do livro lock (objLockSnapshot) { EventoHttpLivroNegocios httpLNG; httpLNG = negociosConsumer.SnapshotStreamerLivroNegocios(instrumento); httpLNG.cabecalho = cabecalho; logger.Debug("Snapshot LNG de " + instrumento + ": " + httpLNG.negocio.Count + " items"); mensagem = JsonConvert.SerializeObject(httpLNG); mensagem = MDSUtils.montaMensagemHttp(ConstantesMDS.TIPO_REQUISICAO_LIVRO_NEGOCIOS, instrumento, null, mensagem); queueToStreamer.Enqueue(mensagem); } }
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); } } } }