Connect an application that uses the IBM® Integration API to an integration node, to send requests about its status and its resources.
You must complete the steps in Configuring an environment for developing and running custom integration applications.
Review the following example application, BrokerRunStateChecker.java, which demonstrates how to use the IBM Integration API classes:
import com.ibm.broker.config.proxy.*;
public class BrokerRunStateChecker {
public static void main(String[] args) {
// The IP address of where the integration node is running
// and the web administration port number of the integration node.
displayBrokerRunState("localhost", 4414);
}
public static void displayBrokerRunState(String hostname, int port) {
BrokerProxy b= null;
try {
BrokerConnectionParameters bcp =
new IntegrationNodeConnectionParameters(hostname, 4414);
b = BrokerProxy.getInstance(bcp);
String brokerName = b.getName();
System.out.println("Integration node '"+brokerName+
"' is available!");
b.disconnect();
} catch (ConfigManagerProxyException ex) {
System.out.println("Integration node is NOT available"+
" because "+ex);
}
}
}
This example application connects to a remote integration node.
Review each part of the application that uses the IBM Integration API to understand what is required to connect to an integration node. Use the following steps to assist you in creating your own custom integration applications.
The first line of code inside the try block of the displayBrokerRunState() method instantiates a BrokerConnectionParameters object. BrokerConnectionParameters is an interface that states that implementing classes are able to provide the parameters to connect to an integration node.
The IntegrationNodeConnectionParameters class implements this interface by defining a set of HTTP connection parameters. The constructor that is used in the program has two required parameters:
BrokerConnectionParameters bcp =
new IntegrationNodeConnectionParameters(hostname, 4414, "user", "password");
For
any existing compiled integration (CMP)
applications that were created and compiled before IBM Integration Bus Version 10.0, you can apply the user name and
password in one of the following ways:-DMQSI_CMP_USERNAME=username -DMQSI_CMP_PASSWORD=password
Replace
username with the user name, and
password with its associated password.MQSI_CMP_USERNAME, MQSI_CMP_PASSWORD
String filename = "C:\\my.broker";
IntegrationNodeConnectionParameters bcp = new IntegrationNodeConnectionParameters(filename);
For
more information about how to create a .broker
file, see Connecting to an integration node by creating a .broker file.BrokerConnectionParameters bcp =
new IntegrationNodeConnectionParameters(hostname, 4414, "user", "password", true);
This
SSL constructor uses the JVM trust store; however, you can supply the location
of an alternative trust store by using a .broker file. For
more information, see Connecting to an integration node by creating a .broker file.b = BrokerProxy.getLocalInstance("IBNODE");
getName(), and other methods that request information from the integration node, cause a block until the information is supplied, or a timeout occurs. Therefore, if the integration node is not running, the application hangs for a period. You can control the timeout period by using the BrokerProxy.setRetryCharacteristics() method. Typically, blocking occurs only when a resource is accessed for the first time within an application.
You can create a custom integration application that can connect to an integration node.
When a BrokerProxy handle is first returned from the getInstance() method, the integration node service does not have to be running. It is only when the application uses the handle (by calling the getName() method in this example) that the application can be assured that a two-way connection with the integration node is active.