...
- Input message content and properties can be accessed using document object. For example, 'document.getText()' returns input message content. To access a message property named 'TestProperty, 'document.getRecord().getProperty('TestProperty')' returns the value of the property. All the Properties can be accessed using document.getRecord().getProperty('PropertyName').
- Message properties can be set using 'document.getRecord().setProperty(String name, Object value)' method.
- Message properties which are set on input message also appear on output message unless they are changed in the script. For example, if a property named 'TestProperty' is present on input message then output message also contains the property unless it is changed in script provided.
- Output message content can be set either by using 'document.setText(String value)' of document object.
- In message properties, property with name 'ESBX__SYSTEM__CARRY_FORWARD_CONTEXT' contains application context object.
Application context schema can be accessed using document.getRecord().getProperty("ESBX__SYSTEM__CARRY_FORWARD_CONTEXT").getAppContext() method.
Similarly setAppContext(String appContext) can be used to modify application context. - JMS Correlation ID can be accessed/set using document.getRecord().getJMSCorrelationID() and document.getRecord().setJMSCorrelationID(String correlationID) methods.
Accessing Source Contexts
Carry forward context contains a vector of source context objects in the service execution order. This vector is updated after every service instance execution.
Following code returns an Enumeration of Source context objects.
Code Block |
---|
contexts = document.getRecord().getProperty("ESBX__SYSTEM__CARRY_FORWARD_CONTEXT").getContexts(); |
contexts.hasMoreElements()
can be used to iterate over the enumerationcontexts.nextElement()
can be used to get the context object.
Context object contains Service Instance Name, Application Name, Application Version, Node Name. Following codes can be used to access the respective fields.
Method | Description |
---|---|
getSrvInstName() | Returns Service Insatnce Name for this context object. |
getAppInstName() | Returns Application Insatnce Name to which service instance belongs. |
getNodeName() | Returns Node Name on which service instance is running. |
getAppInstVersion() | Returns Version of the application to which service instance belongs. |
Example
Following script can be used to get the list of service instances that a message has passed through
Code Block |
---|
contexts = document.getRecord().getProperty("ESBX__SYSTEM__CARRY_FORWARD_CONTEXT").getContexts();
instanceList = "";
while(contexts.hasMoreElements()){
instanceList = instanceList + contexts.nextElement().getSrvInstName() + ",";
}
document.setText(instanceList); |
Anchor | ||||
---|---|---|---|---|
|
...
Overview
Content Tools
ThemeBuilder