WebSphere WebSphere Application Server Network Deployment, Version 6.0.x Operating Systems: AIX, HP-UX, Linux, Solaris, Windows

Working with the message properties

This topic describes how to work with the message properties to affect subsequent processing.

Before you start this task, you should read about the properties that are supported by the SIMessage interface in Message properties support for mediations.
There are two different types of message 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 using the SIMessage interface (see SIMessage.) There are three different sets of methods:

Typically, you can work with message properties in the following way, when programming a mediation:
  1. Locate the point in your mediation handler where you insert the functional mediation code, in the method handle (MessageContext context). The interface is MessageContext, and you should cast this to SIMessageContext unless you are only interested in the methods provided by MessageContext.
  2. Get the SIMessage from the MessageContext object. For example, SIMessage message = ((SIMessageContext)context).getSIMessage();
  3. Build your mediation header function in a similar way to these examples, using the reference information in Message properties support for mediations to help:
    1. Get a user property of the message. For instance, String task = (String)msg1.getUserProperty("task");. In this case, the task string may refer to an operation that the mediation should perform.
    2. Set a user property, where message Properties are stored as name-value pairs. The setUserProperty method may only be used to set user properties, so the name passed into the method should not include the "user." prefix. For example, msg1.setUserProperty("background","green");
    3. Delete a user property from the message. For instance, msg1.deleteUserProperty("task");

Mediation function code to work with message properties may 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();
      }
    }     

Task topic

Terms of Use | Feedback

Last updated: 5 Oct 2005
http://publib.boulder.ibm.com/infocenter/ws60help/index.jsp?topic=/com.ibm.websphere.pmc.nd.doc\tasks\tjy1504.html

© Copyright IBM Corporation 2004, 2005. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)