Creating a simple filter using a JavaCompute node

Before you start

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

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. Use the JavaCompute node creation wizard to generate template code for a filter node:
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 broker 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.

Related tasks
Propagating a message to the JavaCompute node Out and Alternate terminals
Related reference
JavaCompute node