A connector is a collection of that define operations users can call from their ESB configurations to easily access specific logic for processing messages. Typically, connectors are used to wrap the API of an external service. For example, there are several default connectors provided with the ESB that call the APIs of services like Twitter and JIRA. You can also create your own connector to provide access to other services. Creating a connector involves the following high-level tasks:
- Research the APIs provided by the service for which you want to create a connector.
- Decide which API you are going to use to write the connector. For example, JIRA provides a REST API and Java API. If you choose the REST API, you can create your connector and operations entirely from XML configuration files. If you choose a Java API, you create XML configuration files that define your connector and point to your Java classes that define the operations.
- Use the connector core libraries to write your connector.
- After you create the files, you package them in a ZIP file, which you can then add to an ESB instance.
This page describes the structure of the configuration files you create for your connector, and best practices for creating connectors.
Creating the configuration files
Use your IDE to create a Maven project, and create a directory structure similar to the following:
Following is a description on the required files shown above.
pom.xml- Contains the required dependencies for the connector core libraries and relevant Synapse libraries, as well as Maven repositories for the specific connector (such as JIRA Maven repositories for a JIRA connector).
assemble-connector.xml- Contains the instructions to create the connector archive (ZIP) file.
connector.xml- Defines the connector name, package, and the different categories of operations that will be exposed for the connector. For example, the JIRA connector's connector.xml file looks like this:
For each of the categories you specify, you create a corresponding directory (as shown above in the directory tree), each of which contains a
component.xml- Contains information about the operations in this category. For example, in the
component.xmlfile looks like this:
Each operation is specified as a separate sub-component of the operation group.
<operation-name>.xml- Contains the actual API calling configuration. This file contains the steps necessary to call the API exposed by the service. For example, the
createFilteroperation defined above points to the file
createFilter.xml, which uses templates to define the configuration: