Class Hierarchy All Classes All Fields and Methods

Interface com.ibm.broker.plugin.MbInputNodeInterface

public interface MbInputNodeInterface

MbInputNodeInterface provides the mechanism for creating a user plugin input node. Each input node must implement MbInputNodeInterface and extend MbInputNode as follows:

public class MyInputNode extends MbInputNode implements MbInputNodeInterface
{
  private String _attribute1, _attribute2;

  public MyInputNode() throws MbException
  {
    // create terminals here
    createOutputTerminal("out");
    createOutputTerminal("failure");
    createOutputTerminal("catch");
  }

  public int run(MbMessageAssembly assembly) throws MbException
  {
    // do node processing here
    // ...
    // if waiting for input for more than say 5 seconds, timeout and return
    // TIMEOUT

    // Create a new message from the input data
    String str = "Get the data from somewhere";
    byte[] bytes = str.getBytes();
    MbMessage msg = createMessage(bytes);
    MbMessageAssembly newAssembly = new MbMessageAssembly(assembly, msg);

    // all input 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(newAssembly);

    //return SUCCESS_RETURN;
    return SUCCESS_CONTINUE;
  }

  // the following static method declares the name of this node to the broker
  public static String getNodeName()
  {
    return "ComIspSampleInputNode";
  }
 
  // 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), three output terminals (out, failure, catch) 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. For an input node the default attributes 'rootParserClassName' and 'firstParserClassName' are automatically handled by the framework.

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.

The 'failure' and 'catch' terminals will be automatically handled by the framework provided they have been created in the node constructor.

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 Index
Field Description
copyright  
Method Index
Method Description
int run(MbMessageAssembly) This is called by the broker for each message passed through the message flow.

Fields

copyright

public static final java.lang.String copyright

Methods

run

public int run(MbMessageAssembly assembly) throws MbException

This is called by the broker for each message passed through the message flow. This is where the functionality of the node is contained. The node developer should ensure that this method does not wait on an imput message for a prolonged period, but yields control to the broker periodically using the return value TIMEOUT. After a message has been obtained and propagated to an output terminal, one of the following values should be returned:

Class Hierarchy All Classes All Fields and Methods