Pattern
authoring
You can connect both subflow and built-in nodes. The first example shows you how to
connect two built-in nodes. The second example shows you how to connect a built-in node
to a subflow node.
To use the terminals of a subflow node, 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);
The
following example shows you how to connect two built-in nodes:
- A MQInput node and a Collector node are created.
- The getInputTerminal() method is used to create a dynamic
Input terminal called NEWIN on the Collector node.
- The Input terminal is connected to the Output terminal of the MQInput node by using the
connect() method of the message flow object
mf1.
File msgFlow = new File("main.msgflow");
MessageFlow mf1 = FlowRendererMSGFLOW.read(msgFlow);
MQInputNode mqinNode = new MQInputNode();
mqinNode.setNodeName("My Input Node");
mqinNode.setQueueName("INPUTQ");
CollectorNode colNode = new CollectorNode();
colNode.getInputTerminal("NEWIN");
mf1.connect(mqinNode.OUTPUT_TERMINAL_OUT, colNode.getInputTerminal("NEWIN"));
To
use a static terminal on a node, you must use the appropriate constant defined for
it in the IBM Integration
API. These constants are listed
in the IBM Integration
API javadoc, see IBM Integration
API.
The following example shows you
how to connect a subflow node to a built-in node. You must load the subflow message
flow and link it to a subflow node. You must use the
getInputTerminal(),
getInputTerminals(),
getOutputTerminal() or
getOutputTerminals() method to access the terminal on the
subflow node to which you want to connect. The example code completes the following steps:
- The main message flow, main.msgflow, and a Compute node in the main message flow
are loaded into memory.
- The subflow message flow, subflow.msgflow, and the subflow node in the main
message flow are loaded into memory.
- The setSubFlow() method of the subflow node is used to
link the subflow message flow sub1 to the subflow node
sfNode.
- The getOutputTerminal() method is used to get the Process
terminal of the subflow node. The connect() method of the
message flow object is used to connect this terminal to the Input terminal
of the Compute node.
File msgFlow = new File("main.msgflow");
MessageFlow mf1 = FlowRendererMSGFLOW.read(msgFlow);
ComputeNode compNode = (ComputeNode)mf1.getNodeByName("My Compute Node");
File subFlow = new File("subflow.msgflow");
MessageFlow sub1 = FlowRendererMSGFLOW.read(subFlow);
SubFlowNode sfNode = (SubFlowNode)mf1.getNodeByName("My Subflow Node");
sfNode.setSubFlow(sub1);
mf1.connect(sfNode.getOutputTerminal("Process"), compNode.INPUT_TERMINAL_IN);
The following example is the same as the previous example for
connecting two build-in nodes, but for pattern authoring:
MessageFlow mf1 = patternInstanceManager.getMessageFlow("MyFlowProject", "main.msgflow");
MQInputNode mqinNode = new MQInputNode();
mqinNode.setNodeName("My Input Node");
mqinNode.setQueueName("INPUTQ");
CollectorNode colNode = new CollectorNode();
colNode.getInputTerminal("NEWIN");
mf1.connect(mqinNode.OUTPUT_TERMINAL_OUT, colNode.getInputTerminal("NEWIN"));
The
following example is the same as the previous example for using static terminals on
a node, but for pattern authoring:
MessageFlow mf1 = patternInstanceManager.getMessageFlow("MyFlowProject", "main.msgflow");
ComputeNode compNode = (ComputeNode)mf1.getNodeByName("My Compute Node");
MessageFlow sub1 = patternInstanceManager.getMessageFlow("MyFlowProject", "subflow.msgflow");
SubFlowNode sfNode = (SubFlowNode)mf1.getNodeByName("My Subflow Node");
sfNode.setSubFlow(sub1);
mf1.connect(sfNode.getOutputTerminal("Process"), compNode.INPUT_TERMINAL_IN);