Use the Database Lookup mediation primitive to modify a message, using information from a database.
The Database Lookup mediation primitive can add to, or change, messages. It does this using information from a user-supplied database.
This mediation primitive looks up values from a database and stores them as elements in the message. The information obtained from the database might need converting to the correct type to be stored in the message. This is specified using the Message value type property. If the information obtained from the database cannot be converted into the type expected by the message, then an exception occurs.
If a message element already exists in the message then the old value is overwritten with the new value. If the new value is not compatible with the element type defined by property Message value type, then an exception occurs.
The Database Lookup mediation primitive needs various database information, including a key. The key is found using a property called Key path. If the Key path key does not exist in the input message, then an exception occurs.
The Database Lookup mediation primitive has one input terminal and three output terminals. The input terminal is wired to accept a message and the output terminals are wired to propagate a message. One output terminal is used if the Key path key is located both in the message and the database. In this case, the information obtained from the database is stored in the message and the updated message is propagated. Another output terminal is used if the Key path key is found in the message but not in the database. In this case, the original message is propagated unchanged. The last output terminal is used for failure output. If an exception occurs during the processing of the input message, then the fail terminal propagates the original message, together with any exception information.
You can use the Database Lookup mediation primitive to ensure information in a message is up-to-date.
You can use the Database Lookup mediation primitive to add information to a message, using a key contained in a message. For example, the key could be an account number.
It is often useful to combine the Database Lookup mediation primitive with other mediation primitives. For example, you might use an XSLT mediation primitive to manipulate data, before or after the Database Lookup is invoked.
Property | Valid Values | Default | |
---|---|---|---|
Data source name | String | ||
Table name | String: | ||
Key column name | String | ||
Key path | String | ||
Data elements | Value column name | String | |
Message value type | String: defining Java primitive or Java String | ||
Message element | String: an XPath expression describing the path location of a message element | ||
Validate input | Boolean: true or false | false |
Consider the following when using the Database Lookup mediation primitive: