Updating the local environment with a .NETCompute node

The local environment tree is part of the logical message tree where you can store information while the message flow processes the message.

About this task

In the following example, the C# Evaluate method, which is executed by a .NETCompute node, creates an output message assembly based on the input message assembly. The local environment that enters the .NETCompute node is copied and then updated with the name of a queue which can be used as a DestinationList to dynamically control the behavior of a later MQOutput node.
        public override void Evaluate(NBMessageAssembly inputAssembly)
        {
            NBOutputTerminal outTerminal = OutputTerminal("Out");
            // This code creates an output Assembly based on the input Assembly
            // The Local Environment is copied and editted to provide a dynamic override for the MQOutput node
            NBMessage inputLocalEnvironment = inputAssembly.LocalEnvironment;
            NBMessage outputLocalEnvironment = new NBMessage(inputLocalEnvironment);
            NBElement mqLE = outputLocalEnvironment.RootElement.CreateFirstChild(null, "Destination").CreateFirstChild(null, "MQ");
            mqLE.CreateFirstChild(null, "DestinationData").CreateFirstChild(null, "queueName", "DOTNET.OUT");
            NBMessageAssembly outAssembly = new NBMessageAssembly(inputAssembly, inputAssembly.Message, outputLocalEnvironment, inputAssembly.ExceptionList);                              
            outTerminal.Propagate(outAssembly);
        }

For information about the .NET classes and methods that are supported in IBM® App Connect Enterprise, see the .NET API documentation.