Dynamic View Services > Implementing a Dynamic View Server and its Components > Dynamic View Server in Multithread Mode > Sending Requests in Multithread Mode
 
Sending Requests in Multithread Mode
When working in multithread mode, Rogue Wave® Server lets you start a specific thread which is associated with each connection of a remote component. That thread is responsible for sending feedback messages—such as notification, acknowledgement, or rollback messages—to this component. This service ensures that the server is never blocked by delays due to the communication layer. The sending threads are not synchronized with the notification cycle. Thus, they can be useful to ensure that the server is more responsive, even on monoprocessor machines.
You can start a sending thread yourself when a new component connects by calling the function IlsMvEndPoint::startSendThread. IlsMvEndPoint is a superclass of IlsMvComponentItf.
Besides executing sending threads manually, you can also select automatic mode when initializing the dynamic view server, as follows:
IlsMvServer::Initialize(argc,argv,ILS_THREADED_SEND)
You can also use one of the following modes:
*ILS_THREADED_DEFAULT: This is the default initialization mode. In this case, the dynamic view server selects its execution mode depending on how the environment variable ILS_THREADED_SEND is set.
*If this variable is not set, the execution mode is ILS_SINGLE_THREAD.
*-ilsthread sender: This predefined command line option allows you to start a dynamic view server in threaded sender mode (see IlsMvServer). The server must be compiled in multithreaded mode to accept this option.
When messages are sent to a slow client in a communication layer, the sending primitives may block when the communication buffer is full. If the dynamic view server executes in single-thread mode, it may becomes unresponsive for a long time. Deadlocks can even occur if the same client tries to send a large amount of data and also blocks while writing to the communication buffer. Initializing the view server in multithread mode prevents such situations, as only the thread dedicated to the slow client will block and the server will still be able to process incoming messages.
Nevertheless, you should be aware that the memory queue installed between the main thread and the component thread may grow if the sending thread stays blocked too long. This situation may result in a memory overflow. You can monitor this queue by overriding the function IlsMvUser:: updateSendingQueueLength. This method is called by the main thread of the view server when an update message is added to the queue and by the sending thread when a message is extracted to be sent to the component.
From this method, you may take the decision to close the connection by invoking IlsMvComponentItf::requestDisconnect.

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.