Storing and using elements in the message context
Store an element in the message context so that it is available for use later in the mediation flow. First, add the element as an empty business object in the message context. Then, initialize it by using a mediation primitive such as Message Element Setter to add a value to the business object field.
About this task
- correlation
- makes the property persist throughout the duration of the request and response flows, and is used for passing values from the request flow to the response flow.
- transient
- makes the property available for the duration of the current flow (either the request flow or the response flow), and is used to pass values between mediation primitives in the same flow.
- shared
- element is available during aggregation operations using the Fan Out / Fan In combination. This context should not be used outside aggregation operations.
Follow these steps to set a property in the correlation or transient context of your flow:
Procedure
What to do next
Alternatively you can use the tray on the right side of the mediation flow editor to set the contexts.
To use this, click the + button next to the context and select the business object from the list. You can use an XPath 1.0 expression to access the element from any mediation primitive in the flow, except Fail and Stop. For example, to access the transient element oneWayStreet, use this XPath expression:/context/transient/oneWayStreet
You can then use the property in the following ways:
- Set a value for the element directly into the business object field by using a Message Element Setter or Database Lookup primitive.
- Use the element in an Endpoint Lookup primitive to query the WebSphere® Service Registry Repository.
- Map the element between the context and the message body by using a Mapping primitive or a business object map primitive.
- Write your own custom mediation primitive to set or get the element.