(WMB) Local & Global env in Java Compute node

Local Environment :

  • 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); 

17 comments:

  1. How to call a external java service from a java compute node is it possible??

    Thanks In Advance,
    Srinivas mamidala
    srinivasmmdl.eidiko@gamil.com

    ReplyDelete
  2. yes, It's possible. You need to import your service package inside the service where you want to call the java service.

    ReplyDelete
  3. Hi, Thanks Nice post and one doubt, How do I know whether to use LocalEnvrionment or Global environment?

    ReplyDelete