Working with message properties
You can work with the message properties to affect subsequent processing.
Before you begin
About this task
There are two different types of message properties:
- System properties (including JMS headers, JMSX properties, and JMS_IBM_properties)
- User properties.
You can work with message properties to affect which messages a later mediation should process, or to affect processing by a downstream application or mediation. The rule set in the selector field during mediation configuration tests values in the message properties.
You can access, modify and clear properties by using the SIMessage interface (see SIMessage.) There are three different sets of methods:
- These properties operate on system properties, plus user properties
if the name is qualified with a prefix user.:
- getMessageProperty
- setMessageProperty
- deleteMessageProperty
- clearMessageProperties
- These properties operate on user properties only, without the
need for the prefix user.:
- getUserProperty
- setUserProperty
- deletUserProperty
- clearUserProperties
- getUserPropertyNames returns a list of the names of the user properties in the message.
Procedure
Example
Mediation function code to work with message properties might look similar to the code snippet in this example:
String task = (String)msg1.getUserProperty("task");
if (task != null) {
if (task.equals("addColor")) {
msg1.setMessageProperty(SIProperties.JMS_IBM_Format, "colorful");
msg1.setUserProperty("background","green");
msg1.setUserProperty("foreground","purple");
msg1.setUserProperty("depth",new Integer(3));
msg1.deleteUserProperty("task");
}
else {
msg1.clearUserProperties();
}
}