The Control Bus describes a number of approaches to monitor the health of the message processing system. Each component in the system can publish periodic "heartbeat" messages to the control bus in order to keep the monitoring mechanism informed that the component is still active. The heartbeat messages can contain vital stats of the component as well, such as the number of messages processed, the average time required to process a message or the percentage of CPU utilization on the machine.
What happens, though, if a component is actively processing messages, but garbles outgoing messages due to an internal fault?
Therefore, use Test Message to assure the health of message processing components (see Figure).
The Test Message pattern relies on the following components:
- The Test Data Generator creates messages to be sent to the component for testing. Test data may be constant, driven by a test data file or generated randomly.
- The Test Message Injector inserts test data into the regular stream of data messages sent to the component. The main role of the injector is to tag messages in order to differentiate 'real' application messages from test messages. This can be accomplished by inserting a special header field. If we have no control over the message structure, we can try to use special values to indicate test messages (e.g. OrderID = 999999). This changes the semantics of application data by using the same field to represent application data (the actual order number) and control information (this is a test message). Therefore, this approach should be used only as a last resort.
- The Test Message Separator extracts the results of test messages from the output stream. This can usually be accomplished by using a Content-Based Router.
- The Test Data Verifier compares actual results with expected results and flags an exception if a discrepancy is discovered. Depending on the nature of the test data, the verifier may need access to the original test data.
... Read the entire pattern in the book Enterprise Integration Patterns
Related patterns:
Content-Based Router, Control Bus, Return Address, Loan Broker System Management