public interface MbNodeInterface
MbNodeInterface provides the mechanism for creating a user plugin (non-input) node. Each node must implement MbNodeInterface and extend MbNode as follows:
public class MyNode extends MbNode implements MbNodeInterface { private String _attribute1, _attribute2; public MyNode() throws MbException { // create terminals here createInputTerminal("in"); createOutputTerminal("out"); createOutputTerminal("failure"); } public void evaluate(MbMessageAssembly assembly, MbInputTerminal in) throws MbException { // do node processing here // ... // all nodes (except output nodes) should propagate a message assembly // to the next node in the message flow via an output terminal. MbOutputTerminal out = getOutputTerminal("out"); if(out != null) out.propagate(assembly); } // the following static method declares the name of this node to the broker public static String getNodeName() { return "ComIspSampleNode"; } // by supplying the following two methods, the broker infers this node // has an attribute named 'firstAttribute'. public String getFirstAttribute() { return _attribute1; } public void setFirstAttribute(String attr) { _attribute1 = attr; } // by supplying the following two methods, the broker infers this node // has an attribute named 'secondAttribute'. public String getSecondAttribute() { return _attribute2; } public void setSecondAttribute(String attr) { _attribute2 = attr; } public void onDelete( ) { // perform node clean up if necessary. } }
This node has one input terminal (in), two output terminals (out, failure) and two attributes (firstAttribute, secondAttribute). The attributes are defined by supplying the get/set methods using the standard JavaBean property naming convention. The setXxx method is invoked by the message broker when a configuration request is received that attempts to set the value of the node attribute with matching name xxx.
The name of this node is declared to the broker by supplying the static method 'getNodeName()'. If this method is not supplied, then the broker will give it a default name based on the Java package/class name of the node.
A void onDelete( )
method can be added to the node
implementation. If implemented this will be called when the node is deleted,
for example if a message flow containing the node is redeployed. The method
can be used to perform cleanup, for example closing a connection or freeing
some resource.
Field | Description |
---|---|
copyright |
Method | Description |
---|---|
void evaluate(MbMessageAssembly, MbInputTerminal) | This is called by the broker for each message passed through the message flow. |
public static final java.lang.String copyright
public void evaluate(MbMessageAssembly assembly, MbInputTerminal inputTerminal) throws MbExceptionThis is called by the broker for each message passed through the message flow. This is where the functionality of the node is contained.
The message assembly object passed in is read only. To change the contents of a message will require new message and message assembly objects to be created using the copy constructors. The following code snippet is a common idiom:
... MbMessage newMsg = new MbMessage(assembly.getMessage()); MbElement rootElement = newMsg.getRootElement(); // Use MbElement methods to traverse and modify the message. MbMessageAssembly newAssembly = new MbMessageAssembly(assembly, newMsg); // propagate the new assembly object. ...
- Parameters
- assembly - The message assembly. Read-only
- inputTerminal - The input terminal that the message has been received on.
- Throws