private void enqueueToProcess(QuickFix.FIX44.Message message) { try { queueToProcess.Enqueue(message); } catch (Exception ex) { logger.Error("enqueueToProcess: " + ex.Message, ex); } }
private OrderId GetOrderId(QuickFix.FIX44.Message message) { var brokerOrderId = message.GetField(Tags.OrderID); if (this.orderIdIndex.TryGetValue(brokerOrderId, out var orderId)) { return(orderId); } var newOrderId = new OrderId(message.GetField(Tags.ClOrdID)); this.orderIdIndex[brokerOrderId] = newOrderId; return(newOrderId); }
private void splitterThreadWork() { logger.Info("Iniciando thread de splitter processor"); long lastLog = 0; while (_bKeepRunning) { try { QuickFix.FIX44.Message message = null; if (queueToSplit.TryDequeue(out message)) { logger.Debug("Splitting Message [" + message.Header.GetInt(34) + "] type [" + message.Header.GetString(35) + "]"); List <QuickFix.FIX44.Message> lstSplitted = FIXUtils.splitMessage(message, 0, null); foreach (QuickFix.FIX44.Message splittedmsg in lstSplitted) { enqueueToProcess(splittedmsg); } if (MDSUtils.shouldLog(lastLog)) { logger.Info("Mensagens para splitting FIX na fila: " + queueToSplit.Count); lastLog = DateTime.UtcNow.Ticks; } continue; } Thread.Sleep(25); } catch (Exception ex) { logger.Error("splitterProc: " + ex.Message, ex); } } logger.Info("Thread de splitter finalizada"); }
private void enqueueToSplit(QuickFix.FIX44.Message message) { try { machineGun.EnqueueMessage(message); //queueToSplit.Enqueue(message); //if (queueToSplit.Count == 1) //{ // lock (syncObjSplit) // { // Monitor.Pulse(syncObjSplit); // } //} } catch (Exception ex) { logger.Error("enqueueToSplit: " + ex.Message, ex); } }
private void queueProc() { logger.Info("Iniciando thread de processamento da fila de mensagens FIX"); long lastLog = 0; while (_bKeepRunning) { try { QuickFix.FIX44.Message message = null; if (queueToProcess.TryDequeue(out message)) { if (logger.IsDebugEnabled) { logger.Debug("Processing Message [" + message.Header.GetInt(34) + "] type [" + message.Header.GetString(35) + "]"); } string channelID; string msgtype = message.Header.GetString(QuickFix.Fields.Tags.MsgType); switch (msgtype) { case QuickFix.FIX44.MarketDataIncrementalRefresh.MsgType: if (message.GroupCount(QuickFix.Fields.Tags.NoMDEntries) > 0) { QuickFix.Group MDEntry = message.GetGroup(1, QuickFix.Fields.Tags.NoMDEntries); string securityID = MDEntry.GetString(QuickFix.Fields.Tags.SecurityID); channelID = dctChannel.GetOrAdd(securityID, FIX_DEFAULT_WORKER); } else { channelID = FIX_DEFAULT_WORKER; } break; case QuickFix.FIX44.MarketDataSnapshotFullRefresh.MsgType: if (message.IsSetField(QuickFix.Fields.Tags.SecurityID)) { string securityID = message.GetString(QuickFix.Fields.Tags.SecurityID); channelID = dctChannel.GetOrAdd(securityID, FIX_DEFAULT_WORKER); } else { channelID = FIX_DEFAULT_WORKER; } break; case QuickFix.FIX44.SecurityList.MsgType: if (message.GroupCount(QuickFix.Fields.Tags.NoRelatedSym) > 0) { QuickFix.Group MDEntry = message.GetGroup(1, QuickFix.Fields.Tags.NoRelatedSym); string securityID = MDEntry.GetString(QuickFix.Fields.Tags.SecurityID); string securityType = MDEntry.GetString(QuickFix.Fields.Tags.SecurityType); channelID = dctChannel.GetOrAdd(securityID, securityType); } else { channelID = FIX_DEFAULT_WORKER; } break; case QuickFix.FIX44.SecurityStatus.MsgType: if (message.IsSetField(QuickFix.Fields.Tags.SecurityID)) { string securityID = message.GetString(QuickFix.Fields.Tags.SecurityID); channelID = dctChannel.GetOrAdd(securityID, FIX_DEFAULT_WORKER); } else { channelID = FIX_DEFAULT_WORKER; } break; default: channelID = FIX_DEFAULT_WORKER; break; } EventoFIX eventoFIX = new EventoFIX(); eventoFIX.ChannelID = channelID; eventoFIX.MarketDepth = ConstantesUMDF.UMDF_MARKETDEPTH_MARKET_BY_ORDER; eventoFIX.Message = message; eventoFIX.MsgSeqNum = message.Header.GetInt(QuickFix.Fields.Tags.MsgSeqNum); eventoFIX.MsgType = msgtype; eventoFIX.StreamType = StreamTypeEnum.STREAM_TYPE_TCP_CONFLATED; ContainerManager.Instance.EnqueueFIX(eventoFIX); if (MDSUtils.shouldLog(lastLog)) { logger.Info("Mensagens FIX para processar na fila: " + queueToProcess.Count); lastLog = DateTime.UtcNow.Ticks; } continue; } Thread.Sleep(25); } catch (Exception ex) { logger.Error("queueProc: " + ex.Message, ex); } } logger.Info("Thread de fila de mensagens FIX finalizada"); }
public bool Send(QuickFix.FIX44.Message msg) { return(session.Send(msg)); }