Accessing headers with a .NETCompute node
Use a .NETCompute node to access headers in the message assembly.
About this task
For more information about the contents of these and other WebSphere MQ headers for which IBM® Integration Bus provides a parser, see Element definitions for message parsers.
The following
C# code shows how to add an MQMD header and an MQRFH2 header to your
message using a .NETCompute node:
public override void Evaluate(NBMessageAssembly inputAssembly)
{
NBOutputTerminal outTerminal = OutputTerminal("out");
NBMessage inputMessage = inputAssembly.Message;
// Create a new empty message, ensuring it is disposed after use
using (NBMessage outputMessage = new NBMessage())
{
NBMessageAssembly outAssembly = new NBMessageAssembly(inputAssembly, outputMessage);
NBElement inputRoot = inputMessage.RootElement;
NBElement outputRoot = outputMessage.RootElement;
#region UserCode
// Add user code in this region to create a new output message
NBElement MQMD = outputRoot.CreateLastChildUsingNewParser(NBParsers.NBHeaderParsers.MQMD.ParserName);
NBElement MQRFH2 = outputRoot.CreateLastChildUsingNewParser(NBParsers.NBHeaderParsers.MQRFH2.ParserName);
#endregion UserCode
// Change the following if not propagating message to the 'Out' terminal
outTerminal.Propagate(outAssembly);
}
}