Validating messages

Before you start:

Read the concept topics about message flow nodes and the MRM parser and domain.

The broker provides validation based on the message dictionaries for predefined messages. Validation, therefore, applies only to messages that you have modeled and defined to the MRM domain.

The broker does not provide any validation for self-defining messages. You can not validate messages directly against an XML DTD or XML Schema. Instead you should create the equivalent model in the MRM domain by importing your XML DTD or XML Schema using the Message Brokers Toolkit

Message flows are designed to transform and route messages that conform to certain rules. By default, the MRM parser performs some validity checking on a message, but only to ensure the integrity of the parsing operation. However, you can validate a message more stringently against the message model contained in the message dictionary, by specifying validation options on certain nodes in your message flow.

You can use validation options to validate the following messages:

These validation options can guarantee the validity of data entering and leaving the message flow. The options provide you with some degree of control over the validation performed to:

You can also specify what action to take when validation fails.

Message validation involves navigating a message tree and checking its validity. It is an extension of tree creation when the message is parsed, and an extension of bit stream creation when the output message is written.

Validation options are available on the following nodes:

Node type Nodes with validation options
Input node MQInput, SCADAInput, HTTPInput, JMSInput, TimeoutNotification
Output node MQOutput, MQReply, SCADAOutput, HTTPReply, JMSOutput
Other nodes Compute, Mapping, JavaCompute, Validate, ResetContentDescriptor, MQGet, HTTPRequest,

Validation options can also be specified on the ESQL CREATE statement and ASBITSTREAM function.

To validate input messages received on an input node, you can specify validation properties on the input node. The input message is then validated as the message bit stream is parsed to form the message tree.

You can also use the Parse Timing property of the input node to control whether the entire message is to be parsed and validated at this time, or whether individual fields in the message are parsed and validated only when referenced.

To validate output messages created by a Compute node, a Mapping node, or a JavaCompute node, you either specify validation properties on the node itself, or you specify validation properties on the output node that sends the message. The validation takes place when the message bit stream is created from the message tree by the output node.

Alternatively, you can use a Validate node to validate a message tree at a particular place in your message flow, or you can use the ESQL ASBITSTREAM function within a Compute, Filter or Database node.

A limited amount of validation occurs by default if you leave the validation settings unaltered. At this default level, an exception is thrown if one of the following is true:
  • There is a data mismatch, where, for example, the parser cannot interpret the data provided for the field type specified
  • The order of elements in the output message does not match the order in the logical message tree (CWF and TDS fixed length models only)
Additionally, the MRM parser by default will perform limited remedial action under the following circumstances:
  1. Extraneous fields are discarded on output for fixed formats (CWF and TDS fixed length models only)
  2. If mandatory content is missing, defaults are supplied, if available, on output for fixed formats (CWF and TDS fixed length models only)
  3. If an element's data type in the tree does not match that specified in the dictionary the data type is converted on output to match the dictionary definition if possible, for all formats.

However, using validation options you can request more thorough validation of messages. For example, you might want to validate one or more of the following conditions and throw an exception, or log the errors:

The sample illustrates some of these validation options.

When using validation options, it is important to understand the following behaviour:
  • The Parse Timing property, which controls whether 'on demand' parsing (sometimes called partial parsing) takes place, has an effect on the timing of the validation of input messages, including message headers.

    For more information on Parse Timing, see Validation properties for messages in the MRM domain.

  • If a message tree is passed to an output node, then by default the output node inherits the validation options in force for the message tree. You can override these options by specifying a new set of validation options on the output node.
  • If a message tree is passed as input to a Compute, Mapping, or JavaCompute node, any new output message trees created by the Compute, Mapping, or JavaCompute node have the validation options specified by the node itself (even if the whole message is copied). You can override this behaviour and specify that messages created by the node inherit the validation options of the input message tree.
  • When the bitstream is written and validation options are applied, the entire message is validated. It is possible that the message tree contains an unresolved type (for example, if a Compute node copied an unresolved type from an input message to an output message without resolving it). If such a type is encountered, a validation error occurs because it is not possible to validate the type. To prevent this, ensure that all unresolved types are resolved before they are copied to output messages.

For information about how you can control validation by using different properties, see Validation properties for messages in the MRM domain.

Related concepts
Predefined and self-defining messages
Message flows overview
Related tasks
Designing a message flow
Creating a message flow
Defining message flow content
Related reference
Built-in nodes
Validation properties for messages in the MRM domain