IBM Integration Bus, Version 10.0.0.9 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS


Creating a request connector

Create a request connector by extending the AbstractRequestConnector and AbstractRequestInteraction classes.

Before you begin

Create a connector factory by following the instructions in Creating a connector factory.

About this task

Create a request connector when you want to send data, or publish events to external systems, and receive a response.

The following example shows the Java™ classes that you need to create for a request connector:

This Java class diagram shows the AbstractConnectorFactory, AbstractRequestConnector, and AbstractRequestInteraction classes in the connector framework.

Javadoc documentation for the Connector Framework API is available at Connector API.

Procedure

To create a request connector, complete the following steps.

  1. Create the connector by extending the AbstractRequestConnector class.
    The following example request connector Java file demonstrates how to create a request connector:
    package connector.database;
    
    import com.ibm.connectors.AbstractRequestConnector;
    import com.ibm.connectors.ConnectorException;
    import com.ibm.connectors.RequestInteraction;
    
    public class myRequestConnector extends AbstractRequestConnector {
    
    	@Override
    	public RequestInteraction createRequestInteraction() throws ConnectorException {
    		// TODO Create the request interaction here. The interaction is the object
    		// that represents the actual request (even if it doesn't actually perform it).
    		// The interaction will receive any dynamic properties configured by the message 
    		// flow, as well as the actual data to be sent
    		return null;
    	}
    
    
    }
    The connector framework calls the createRequestInteraction method when a message is to be processed.
  2. Specify the request connector interaction by extending the AbstractRequestInteraction class.
    The following example of a request interaction Java file demonstrates how to create the request interaction:
    package connector.database;
    
    import java.util.Properties;
    
    import com.ibm.connectors.AbstractRequestInteraction;
    import com.ibm.connectors.ConnectorCallback;
    import com.ibm.connectors.ConnectorException;
    
    // The request interaction class performs a request/response with a remote system.
    // Currently, data is received as a byte array, and should return a byte array in 
    // response. Dynamic properties may be passed in to configure the request per-message.
    public class myRequestInteraction extends AbstractRequestInteraction {
    
    	@Override
    	public Object request(Properties overrideProperties, Object data)
    			throws ConnectorException {
    		byte[] input = (byte[]) data;
    		// TODO Implement code here to send the byte data to the external
    		// system. Return the response which currently must be a byte array.
    		byte[] output = new byte[0];
    		return output;
    	}
    
    	@Override
    	public long asyncRequest(Properties overrideProperties, Object data,
    			ConnectorCallback callback) throws ConnectorException {
    		// TODO Request asynchronously and return a 'ticket'. Currently
    		// unsupported/unused.
    		return 0;
    	}
    
    }

What to do next

After you create the connector factory and connector, create the connector.xml descriptor file (see Creating a connector descriptor file).

cb23136_.htm | Last updated 2017-07-17 12:46:58