Connecting to an integration node from a custom integration application

Connect an application that uses the IBM® Integration API to an integration node, to send requests about its status and its resources.

Before you begin

You must complete the steps in Configuring an environment for developing and running custom integration applications.

About this task

Review the following example application, IntegrationNodeStateChecker.java, which demonstrates how to use the IBM Integration API classes:

import com.ibm.integration.admin.proxy.*;

public class IntegrationNodeStateChecker {

	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.
		displayNodeRunState("localhost", 4414);   
	}     

	public static void displayNodeRunState(String hostname, int port) {        

		IntegrationNodeProxy node = new IntegrationNodeProxy(hostname,port,"","",false);

		try {           
			String nodeName = node.getName();           

			System.out.println("Integration node '"+nodeName+               
					"' is available!");                 
		} catch (IntegrationAdminException 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.

Procedure

  1. Import the com.ibm.integration.admin.proxy package, which contains the IBM Integration API Java™ classes.
    This action is in the first line of the application:
    import com.ibm.integration.admin.proxy.*; 

The first line of code inside the try block of the displayNodeRunState() method instantiates an IntegrationNodeProxy object. IntegrationNodeProxy 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:
  1. The host name of the computer that the integration node is running on.
  2. The web administration port (the default is 4414). For more information about port numbers for an integration node, see Configuring the IBM App Connect Enterprise web user interface.
If you have administration security enabled, use constructors for the user name and password. For example:
IntegrationNodeConnectionParameters node = new IntegrationNodeConnectionParameters(hostname,port,"userid","password",false);

  1. The getName() method, 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.

Results

You can create a custom integration application that can connect to an integration node.