Before you start
WebSphere Message Broker provides the source for two sample user-defined nodes called SwitchNode and TransformNode. You can use these nodes in their current state, or you can modify them.
Conceptually, a message processing node is used to process a message in some way, and an output node is used to output a message as a bit stream. However, when you code a message processing node or an output node, they are essentially the same thing. You can perform message processing within an output node, and likewise you can output a message to a bit stream using a message processing node. For simplicity, this topic mainly refers to the node as a message processing node, however, it discusses the functionality of both types of node.
The Java Settings panel is displayed.
Any class that implements the MbNodeInterface and is contained in the broker's classpath (or LIL path) is registered with the broker as a message processing node. When you implement the MbNodeInterface, you must also implement an evaluate method for this class. The evaluate method is called by the broker for each message that is passed through the flow.
package com.ibm.jplugins; import com.ibm.broker.plugin.*; public class BasicNode extends MbNode implements MbNodeInterface
When the node is instantiated, the constructor of the user's node class is called. This is where you create the terminals of the node, and initialize any default values for attributes.
A message processing node has a number of input terminals and output terminals associated with it. The methods createInputTerminal and createOutputTerminal are used to add terminals to a node when the node is instantiated. For example, to create a node with one input terminal and two output terminals:
public MyNode() throws MbException { // create terminals here createInputTerminal ("in"); createOutputTerminal ("out"); createOutputTerminal ("failure"); }
You need to declare the name of the node as it will be identified by the workbench. All node names must end with "Node". You declare the name using the following method:
public static String getNodeName() { return "BasicNode"; }
package com.ibm.pluginsamples; public class BasicNode extends MbNode implements MbNodeInterface { ...
You declare node attributes in the same way as Java Bean properties. You are responsible for writing getter and setter methods for the attributes, and the API framework infers the attribute names using the Java Bean introspection rules. For example, if you declare the following two methods:
private String attributeVariable; public String getFirstAttribute() { return attributeVariable; } publc void setFirstAttribute(String value) { attributeVariable = value; }
The broker infers that this node has an attribute called firstAttribute. This name is derived from the names of the get or set methods, not from any internal class member variable names. Attributes can only be exposed as strings, so you must convert any numeric types to and from strings in the get or set methods. For example, the following method defines an attribute called timeInSeconds:
int seconds; public String getTimeInSeconds() { return Integer.toString(seconds); } public void setTimeInSeconds(String value) { seconds = Integer.parseInt(value); }
As described earlier, for message processing or output nodes, you must implement the evaluate method, defined in MbNodeInterface. This is called by the broker to process the message. This method should provide all the processing function for the node.
The message flow data, that is, the message, global environment, local environment, and exception list, is received at the input terminal of the node.
You implement the onDelete method as follows:
public void onDelete() { // perform node cleanup if necessary }
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
as09970_ |