Creating a simple filter by using a JavaCompute node

The JavaCompute node has two output terminals: Out and Alternate. To use the JavaCompute node as a filter node, propagate a message to either the Out or Alternate terminal based on the message content.

Before you begin

To complete this task, you must have added a JavaCompute node to your message flow.

About this task

Use the JavaCompute node creation wizard to generate template code for a filter node:

Procedure

Select the Filtering Message Class template in the JavaCompute node creation wizard to create a filter node.
The following template code is produced. It passes the input message to the Out terminal without doing any processing on the message.
public class jcn2 extends MbJavaComputeNode {

  public void evaluate(MbMessageAssembly assembly) throws MbException {
    MbOutputTerminal out = getOutputTerminal("out");
    MbOutputTerminal alt = getOutputTerminal("alternate");

    MbMessage message = assembly.getMessage();

    // ----------------------------------------------------------
    // Add user code below

    // End of user code
    // ----------------------------------------------------------

    // The following should only be changed
    // if not propagating message to the 'out' terminal

    out.propagate(assembly);
  }
}

The template produces a partial implementation of a method called evaluate(). The integration node calls evaluate() once for each message that passes through the node. The parameter that is passed to evaluate() is the message assembly. The message assembly encapsulates the message that is passed on from the previous node in the message flow.

Add custom code to the template, and propagate messages to both the Out and Alternate terminals to create a message filter.