JavaCompute node

This topic contains the following sections:

Purpose

Use the JavaCompute node to do one of the following tasks:

  • Examine an incoming message and, depending on its content, propagate it unchanged to one of the node's two output terminals; the node behaves in a similar way to a Filter node, but uses Java instead of ESQL to decide which output terminal to use.
  • Change part of an incoming message and propagate the changed message to one of the output terminals.
  • Create and build a new output message that is totally independent of the input message.

The Java code that is used by the node is stored in an Eclipse Java project.

The JavaCompute node is represented in the workbench by the following icon:

Compute node icon

Using this node in a message flow

The JavaCompute node can be used in three ways:

  • Use the JavaCompute node to look at a message, and propagate the message to an output terminal based on the message content. The message content is not changed and you have read-only access to the message.
  • Use the JavaCompute node to modify a message, and propagate the modified message to an output terminal.
  • Use the JavaCompute node to create a new message, and propagate the new message to an output terminal.

Look at the samples in the Samples Gallery in the Message Brokers Toolkit.

Configuring the JavaCompute node

You can configure each instance of the JavaCompute node that occurs in a message flow.

To do this, right-click the node in the editor view. The Open Java option is presented. Click this property.

The first time that you do this, a wizard is launched that guides you through the creation of a new Java project and a Java class that contains some skeleton code. This skeleton code is presented in a Java editor.

See Creating Java code for a JavaCompute node for examples of the skeleton code or template that are provided.

If this is not the first time that this has been done, you are presented with Java code in a Java compute perspective.

To associate an instance of a JavaCompute node with a Java class, right-click the node in the editor view of the message flow and select Properties and then Basic. The node's basic properties are displayed.

The JavaCompute node has only one basic property. This is Java Class. Enter the name of the Java class that is used in this node. This name must be in the list of JavaCompute node classes that are available in the project references for the message flow project.

All mandatory properties for which you must enter a value (those that do not have a default value defined) are marked with an asterisk on the properties dialog.

When you have completed your configuration, click Apply. This makes the changes to the JavaCompute node without closing the properties dialog.

Alternatively, click OK. This makes the changes to the JavaCompute node and closes the properties dialog.

You can click Cancel to close the dialog and discard all the changes that you have made to the node.

Specifying Java

Code Java statements to customize the behavior of the JavaCompute node.

For example, you can customize it to create a new output message or messages, using input message or database content (unchanged or modified), or new data. For example, you might want to modify a value in the input message by adding a value from a database, and store the result in a field in the output message.

Code the Java statements that you want in a Java file that is associated with the JavaCompute node.

If a Java file does not already exist for this node, right-click the JavaCompute node and click Open Java. This creates and opens a new Java file in the editor view.

If the file already exists, click the Browse button beside the Java Class property. This displays the JavaCompute Node Type Selection dialog, which lists the Java classes that are accessible by this message flow. Select the appropriate Java class and click OK. The list of matching types show suitable Java classes when at least one character is entered in the Select field.
Note: All Java classes are shown if you enter '*' in the Select field.

Validating messages

Set the validation properties to define how the message that is produced by the JavaCompute node is to be validated. Note that these properties do not cause the input message to be validated. It is expected that, if such validation is required, the validation has already been performed by the input node or a preceding Validation node.

For more details refer to Validating messages and Validation properties for messages in the MRM domain.

Terminals and properties

The JavaCompute node terminals are described in the following table.

Terminal Description
In The input terminal that accepts a message for processing by the node.
Failure The output terminal to which the input message is routed if a failure is detected during the computation. (Even if the Validate property is set, messages propagated to the failure terminal of the node are not validated.)
Out The output terminal to which the transformed message is routed.
Alternate An alternative output terminal to which the transformed message can be routed, instead of to the Out terminal.

The following tables describe the node properties; the column headed M indicates whether the property is mandatory (marked with an asterisk on the properties dialog if you must enter a value when no default is defined), the column headed C indicates whether the property is configurable (you can change the value when you add the message flow to the bar file to deploy it).

The JavaCompute node has the Basic property that is described in the following table.

Property M C Default Description
Java Class Yes No None The name of the Java class that is used in this node. This name must appear in the list of Java classes that are available to be used.

The Validation properties of the JavaCompute node are described in the following table.

Property M C Default Description
Validate Yes Yes None Whether validation takes place, and what part of the message is validated. Valid values are None, Content and Value, Content, and Inherit.
Failure Action Yes No Exception What happens if a validation failure occurs. You can set this property only if Validate is set to Content or Content and Value. Valid values are User Trace, Local Error Log, Exception, and Exception List.
Include All Value Constraints Yes No Selected This property cannot be edited. The default action, indicated by the check box being selected, is that all value constraints are included in the validation.
Fix Yes No None This property cannot be edited. Minimal fixing is provided. Valid values are None, and Full.

The properties of the General Message Options for the JavaCompute node are described in the following table.

Property M C Default Description
Parse Timing Yes No On Demand This property controls when an input message is parsed. Valid values are On Demand, Immediate, and Complete.

Refer to Parsing on demand for a full description of this property.

Use MQRFH2C Compact Parser for MQRFH2 Domain No No False This property controls whether the MQRFH2C Compact Parser, instead of the MQRFH2 parser, is used for MQRFH2 headers.

The properties of the XMLNSC Parser Options for the JavaCompute node are described in the following table.

Property M C Default Description
Use XMLNSC Compact Parser for XMLNS Domain Yes Cleared No Start of changeSetting this property causes the outgoing MQRFH2 to specify the XMLNS instead of XMLNSC parser, allowing an external application to remain unchanged. If outgoing messages do not contain MQRFH2 headers this property has no effect.End of change
Mixed Content Retain Mode Yes No None This property controls whether the XMLNSC parser creates elements in the message tree when it encounters mixed text in an input message. Valid values are None and All. Selecting All means that elements are created for mixed text. Selecting None means that mixed text is ignored and no elements are created.
Comments Retain Mode Yes No None This property controls whether the XMLNSC parser creates elements in the message tree when it encounters comments in an input message. Valid values are None and All. Selecting All means that elements are created for comments. Selecting None means that comments are ignored and no elements are created.
Processing Instructions Retain Mode Yes No None This property controls whether the XMLNSC parser creates elements in the message tree when it encounters processing instructions in an input message. Valid values are None and All. Selecting All means that elements are created for processing instructions. Selecting None means that processing instructions are ignored and no elements are created.

The Description properties of the JavaCompute node are described in the following table.

Property M C Default Description
Short Description No No   A brief description of the node.
Long Description No No   Text that describes the purpose of the node in the message flow.
Related concepts
Message flows overview