Use the IBM® Integration API when developing message flow applications to load a message flow into memory. You can then access the message flow in your Java™ code.
The following example shows how to load a message flow that is in the mqsi directory:
import java.io.File;
import java.io.IOException;
import com.ibm.broker.MessageBrokerAPIException;
import com.ibm.broker.config.appdev.MessageFlow;
import com.ibm.broker.config.appdev.FlowRendererMSGFLOW;
public class LoadMessageFlow {
public static void main(String[] args) {
File msgFlow = new File("../mqsi/main.msgflow");
try {
MessageFlow mf1 = FlowRendererMSGFLOW.read(msgFlow);
} catch (IOException e) {
// Add your own code here
e.printStackTrace();
} catch (MessageBrokerAPIException e) {
// Add your own code here
e.printStackTrace();
}
}
}
When you create patterns with the pattern authoring tool, use the getMessageFlow() method of the PatternInstanceManager object, which is automatically passed to your Java code. Modify a pattern instance to load a message flow into memory and make it available to other IBM Integration API methods.
public class MyJava implements GeneratePatternInstanceTransform {
public void onGeneratePatternInstance(PatternInstanceManager patternInstanceManager) {
MessageFlow mf1 = patternInstanceManager.getMessageFlow("MyFlowProject", "main.msgflow");
if (mf1 != null) {
// Message flow was found
}
else {
// Message flow was not found
}
}
}
public class MyJava implements GeneratePatternInstanceTransform {
public void onGeneratePatternInstance(PatternInstanceManager patternInstanceManager) {
MessageFlow mf1 = patternInstanceManager.getMessageFlow("MyFlowProject", "mqsi/main.msgflow");
if (mf1 != null) {
// Message flow was found
}
else {
// Message flow was not found
}
}
}