Local Environment :
Use the full version of the copy constructor to create a new MbMessageAssembly object, as shown in the following example:
MbMessage env = assembly.getLocalEnvironment();
MbMessage newEnv = new MbMessage(env);
newEnv.getRootElement().createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"Status","Success");
MbMessageAssembly outAssembly = new MbMessageAssembly(
assembly,newEnv,assembly.getExceptionList(),assembly.getMessage());
getOutputTerminal("out").propagate(outAssembly);
Global Environment :
The following Java code shows how to alter the Global Environment:
MbMessage env = assembly.getGlobalEnvironment();
env.getRootElement().createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "Status", "Success");
getOutputTerminal("out").propagate(assembly);
- The local environment tree is part of the logical message tree in which we can store information while the message flow processes the message.
- In order to update the local environment, make a new copy of the local environment.
Use the full version of the copy constructor to create a new MbMessageAssembly object, as shown in the following example:
MbMessage env = assembly.getLocalEnvironment();
MbMessage newEnv = new MbMessage(env);
newEnv.getRootElement().createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"Status","Success");
MbMessageAssembly outAssembly = new MbMessageAssembly(
assembly,newEnv,assembly.getExceptionList(),assembly.getMessage());
getOutputTerminal("out").propagate(outAssembly);
Global Environment :
- The Global environment tree is a part of the message and it is created when input message is received. However message flow does not populates the tree or using the contents of the tree .
- The Global Environment can be altered across the message flow, therefore do not make a copy of it to alter.
The following Java code shows how to alter the Global Environment:
MbMessage env = assembly.getGlobalEnvironment();
env.getRootElement().createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "Status", "Success");
getOutputTerminal("out").propagate(assembly);