简体   繁体   English

QuickFIX处理修复消息的线程数

[英]QuickFIX number of threads to handle a fix message

I notice in the code fragment below that in QuickFIX, the threadID is always always the same in that whatever thread id fromApp outputs equals the thread id of MarketDataIncrementalRefresh . 我在下面的代码片段中注意到,在QuickFIX中,threadID始终是相同的,因为fromApp输出的任何线程ID fromApp等于MarketDataIncrementalRefresh的线程ID。 But I also notice that the threads from invocation of fromApp to another fromApp can vary, meaning that QuickFIX is throwing the message onto a different (threadpool?) thread. 但是我还注意到,从调用fromApp到另一个fromApp的线程可能会有所不同,这意味着QuickFIX将消息抛出到了另一个线程池中。

My questions are, (all more or less related) 我的问题是(或多或少都相关)

  1. If I don't get off the thread, am I blocking QF from grabbing another message? 如果我没有离开线程,是否阻止QF获取其他消息?
  2. Is there a parameter that allows me to control how many threads QF uses to manage incoming messages? 是否有一个参数可以让我控制QF用于管理传入消息的线程数?
  3. It seems that if this "number of threads to use" value is high enough, then there is no reason to handle (parse etc) the message received in one the virtual methods, eg, MarketDataIncrementalRefresh in yet another thread? 似乎如果此“要使用的线程数”值足够高,那么没有理由处理(解析等)在另一个线程中通过虚拟方法(例如MarketDataIncrementalRefresh)接收到的消息吗?

void MyApplication::fromApp( const FIX::Message& message, const` FIX::SessionID& sessionID )
    throw( /*FIX::FieldNotFound,*/ FIX::IncorrectDataFormat, FIX::IncorrectTagValue, FIX::UnsupportedMessageType )
    {
        //std::cout << std::endl << "IN: " << message << "\n";

        try
        {
            std::cout << "fromApp " << std::this_thread::get_id() << '\n';
            crack( message, sessionID );
        }
        catch(std::exception& ex)
        {
            std::cout << "crack exception: " << ex.what() << "\n";
        }
    }

void MyApplication::onMessage
    (const FIX44::MarketDataIncrementalRefresh& message, const FIX::SessionID& fsid)
    {
        std::cout << "MarketDataIncrementalRefresh " << std::this_thread::get_id() << '\n';
    }

It appears that there are two ways to instantiate an Initiator: 似乎有两种方法可以实例化启动器:

FIX::SocketInitiator initiator( application, storeFactory, settings);

or 要么

FIX::ThreadedSocketInitiator initiator( application, storeFactory, settings);

But this appears to handle the case where one thread handles multiple sessions or several threads handle different sessions. 但这似乎可以处理一个线程处理多个会话或几个线程处理不同会话的情况。 My question has to do with if the thread that cracks the message and the thread that handles the communications/receiving of the message are the same in these QF threading models. 我的问题与破解消息的线程和处理消息的通信/接收的线程在这些QF线程模型中是否相同有关。 So not quite the same thing I think. 所以我想的不太一样。 In other words, once the message has traveled further into the application. 换句话说,一旦消息进一步传播到应用程序中。

I have also seen code like this: 我也看到过这样的代码:

new SocketAcceptor(3, new ThreadPoolExecutor(3, 3, 1000, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1000)));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM