Adding a node and a subflow node

Use the IBM Integration API when developing message flow applications to add a new node or subflow node to a message flow.

You can add a new built-in node, or a new subflow node to a message flow.
  • When you add a subflow node by using the IBM Integration API, you must link the subflow node with the subflow message flow by using the setSubFlow() method of the subflow node object. For example, if you have assigned your subflow message flow to message flow instance sub1 and you have assigned your subflow node to subflow node instance sfNode, you must use the following statement to link the subflow node with the subflow message flow:
    sfNode.setSubFlow(sub1);
  • If you want to set a node property on a subflow node, use the addNodeProperty() method to set the property before you link the node to the subflow by using the setSubFlow() method. If you use addNodeProperty() after setSubFlow(), the node property might not be stored.
The following example shows you how to add a new built-in node:
File msgFlow = new File("main.msgflow");
MessageFlow mf1 = FlowRendererMSGFLOW.read(msgFlow);
MQInputNode mqinNode = new MQInputNode();
mqinNode.setNodeName("My Input Node");
mqinNode.setQueueName("INPUTQ");
mf1.addNode(mqinNode);
The following example shows you how to add a new subflow node to a message flow:
  1. The new subflow node is added to the message flow held in object mf1.
  2. The subflow node is linked to the subflow message flow by using the setSubFlow() method.
  3. The subflow node name is set to My Sub Flow Node.
  4. A new subflow node is created and assigned to object sfNode.
The subflow can be stored in a .msgflow format:
File msgFlow = new File("main.msgflow");
MessageFlow mf1 = FlowRendererMSGFLOW.read(msgFlow);
File subFlow = new File("subflow.msgflow");
MessageFlow sub1 = FlowRendererMSGFLOW.read(subFlow);
SubFlowNode sfNode = new SubFlowNode();
sfNode.setNodeName("My Sub Flow Node");
sfNode.setSubFlow(sub1);
mf1.addNode(sfNode);
The subflow can be stored in a .subflow format:
File msgFlow = new File("main.msgflow");
MessageFlow mf1 = FlowRendererMSGFLOW.read(msgFlow);
sFile subFlow = new File("subflow.subflow");
MessageFlow sub1 = FlowRendererMSGFLOW.read(subFlow);
SubFlowNode sfNode = new SubFlowNode();
sfNode.setNodeName("My Sub Flow Node");
sfNode.setSubFlow(sub1);
mf1.addNode(sfNode);

Pattern authoring

The following example shows you how to add a new built-in node to a pattern instance:

MessageFlow mf1 = patternInstanceManager.getMessageFlow("MyFlowProject", "main.msgflow");
MQInputNode mqinNode = new MQInputNode();
mqinNode.setNodeName("My Input Node");
mqinNode.setQueueName("INPUTQ");
mf1.addNode(mqinNode);
The following example shows you how to add a new subflow node to a message flow:
MessageFlow mf1 = patternInstanceManager.getMessageFlow("MyFlowProject", "main.msgflow");
MessageFlow sub1 = patternInstanceManager.getMessageFlow("MyFlowProject", "subflow.msgflow");
SubFlowNode sfNode = new SubFlowNode();
sfNode.setNodeName("My Sub Flow Node");
sfNode.setSubFlow(sub1);
mf1.addNode(sfNode);