Skip to content

QFJ Thread Model

Baoying Wang edited this page Jan 27, 2018 · 11 revisions

MORE DETAIL TO BE ADDED

send and recv threads in brief

  • recv : network -> mina IO handler threads -> QFJ Message dispatcher thread - single thread for all session, or separate thread for each session.
  • send: client pub thread(build message, and invoke session.send) -> mina IO handler thread (if block sending is configured, send within client pub thread) (note: refer below - send code skeleton )

ME_1.1_architecture_20180118.png

dispatcher threads for recv in detail

As mentioned in brief, the most important thread setup for recv is how many threads for the session. It is decided by which class is used for your Initiator/Acceptor.

Acceptor/Initiator Thread per session Single Thread for all sessions
Acceptor ThreadedSocketAcceptor SocketAcceptor
Initiator ThreadedSocketInitiator SocketInitiator
  • Thread per session: Accepts connections and uses a separate thread per session to process messages.If you print thread name in Application callback, you will find the dff names for diff sessions.
  • Single Thread for all sessions: a single thread to process messages for all. If you print thread name in Application callback, you will find the same name for diff sessions.

send code skeleton, which will help us to understand the send threads

Session::sendRaw(Message msg, num(always 0)){

    increase seq and set it to msg    
    
    send(String msgStr){
      log msgStr
      responder.send(msgStr){
         netty write(SocketSynchronousWrites=N-default or Y)
      }
    }
    
    persist the msgStr (PersistMessages=Y-default or N)
}

Clone this wiki locally