2.3.1 Enterprise Message API Consumer Architecture
The Enterprise Message API incorporates the ValueAdded Reactor component (called the Transport API VA Reactor) from the Transport API, which provides the watchlist and transport-level functionality. The Enterprise Message API wraps up the reactor component in its own class of OmmConsumer. OmmConsumer provides interfaces to open, modify, and close market items or instruments, as well as submit Post and Generic messages. To complete the set of consumer application functionalities, the OmmConsumer class provides the dispatch() method. Depending on its design and configuration, an application might need to call this method to dispatch received messages. The OmmConsumerConfig class configures the reactor and OmmConsumer.
The OmmConsumerClient class provides the callback mechanism for Enterprise Message API to send incoming messages to the application. The application needs to implement a class inheriting from the OmmConsumerClient class to receive and process messages. By default, OmmConsumerClient callback methods are executed in Enterprise Message API's thread of control. However, you can use the OmmConsumerConfig::operationModel() interface to execute callback methods on the application thread. If you choose to execute callback methods in this manner, the application must also call the OmmConsumer::dispatch() method to dispatch received messages.
While the OmmConsumer class throws an OmmException to report error conditions, the OmmConsumerErrorClient class provides an alternate reporting mechanism via callbacks. To use the alternate error reporting, pass the OmmConsumerErrorClient on the constructor of the OmmConsumer class, which switches the error reporting from exception throwing to callbacks. In addition to its error reporting mechanisms, Enterprise Message API provides a logger mechanism which is useful in monitoring Enterprise Message API behavior and debugging any issues that might arise.
The Enterprise Message API consumer will always have at least one thread, which is implemented by the VA Reactor and runs the internal, VA Reactor logic. For details on this thread, refer to the Transport API C++ Edition Value Added Component Developers Guide. Additionally, you can configure the Enterprise Message API to create a second, internal thread to dispatch received messages. To create a second thread, set the OmmConsumerConfig operation model to OmmConsumerConfig::ApiDispatchEnum. If the OmmConsumerConfig operation model is set to the OmmConsumerConfig::UserDispatch, the Enterprise Message API will not run a second thread. Without running a second thread, the application is responsible for calling the Ommconsumer::dispatch() method to dispatch all received messages.
WARNING! If the application delays in dispatching messages, it can result in slow consumer behavior.