public void Update(EventBean[] newEvents, EventBean[] oldEvents) { EventoBovespa bovEvent = (EventoBovespa)newEvents[0].Underlying; try { filaMensagensLivroOfertas.Push(bovEvent); if (logger.IsDebugEnabled) { logger.Debug("Mensagens na fila: " + filaMensagensLivroOfertas.Count); } } catch (Exception e) { logger.Error(e); } }
/// <summary> /// Handler do evento de recebimento da mensagem /// </summary> /// <param name="LastMsgId"></param> /// <param name="SPF_Header"></param> /// <param name="DataPtr"></param> /// <param name="DataSize"></param> public void OnBovespaDataReceived(string LastMsgId, string SPF_Header, string DataPtr, int DataSize) { string cabecalho; string corpo; string tipo; string instrumento; EventoBovespa msgEvent; long antesSendEvent; long depoisSendEvent; int tamanhoCabecalho = EventoBovespa.BOV_CABECALHO_HORA_EVENTO_FIM; try { if (DataPtr.Length < tamanhoCabecalho) { logger.Error("Tamanho da mensagem invalida [" + DataPtr + "]"); } cabecalho = DataPtr.Substring( EventoBovespa.BOV_CABECALHO_RESERVADO1_INI, EventoBovespa.BOV_CABECALHO_HORA_EVENTO_FIM - EventoBovespa.BOV_CABECALHO_RESERVADO1_INI); corpo = DataPtr.Substring(tamanhoCabecalho); tipo = cabecalho.Substring( EventoBovespa.BOV_CABECALHO_TIPO_MENSAGEM_INI, EventoBovespa.BOV_CABECALHO_TIPO_MENSAGEM_FIM - EventoBovespa.BOV_CABECALHO_TIPO_MENSAGEM_INI); instrumento = cabecalho.Substring( EventoBovespa.BOV_CABECALHO_CODIGO_PAPEL_INI, EventoBovespa.BOV_CABECALHO_CODIGO_PAPEL_FIM - EventoBovespa.BOV_CABECALHO_CODIGO_PAPEL_INI).Trim(); msgEvent = new EventoBovespa(LastMsgId, tipo, cabecalho, corpo, instrumento); antesSendEvent = DateTime.Now.Ticks; epService.EPRuntime.SendEvent(msgEvent); depoisSendEvent = DateTime.Now.Ticks; TimeSpan duracaoSendEvent = new TimeSpan(depoisSendEvent - antesSendEvent); logger.Debug(cabecalho + "-sendEvent em " + duracaoSendEvent.TotalMilliseconds + " ms"); } catch (Exception ex) { logger.Error("Erro em OnDataReceived():" + ex.Message); logger.Error(ex); } }