Monday, October 21, 2013

Mule connector development pointers

This article will be helpful for the mule beginners.

  • Following are some annotation and its meaning
    • @Connector : To mark a class as a Connector.The following is a description of the attributes for this annotation:
      • name: The name of the connector. This is a simple string value which should not contain any spaces in it, it will be used to generate the namespace of the connector.
      • schemaVersion: The version of the generated schema. This usually should match Mule’s schema version, so for .3.1 use schemaVersion=”3.3.1″. Keep in mind that if you add or change methods marked as @Processors or add @Configurable fields the generated schema will change and you should bump the version to avoid compatibility issues.
      • friendlyName: This is the name of the connector and is meant to be used only in Studio. This name will appear as the module name in the palette. Contrary to the name parameter, this field can contain spaces.
      • Connector class
      • minMuleVersion: The minimum version of Mule that this connector supports. A check will be generated for runtime verification that the Mule version this connector is running on is the correct one.
    • @Configurable : To involve a field in configuration
    • Configurable Attribute
    • @Connect : To establish connection to the Service
      • ConnectionKey : annotated parameter is used as the key to the pool. Thus, the Connector can be invoked using a number of different credentials
      Connect method
    • @Start : An alternative to connect annotation.If you don’t want to exploit the connection pool facility you can use this.This will mean you can have a single instance per configuration.
      Start method
    • @Processor : To mark a method as an operation

    • @Disconnect :  Invoked when as part of the maintenance of the Connection Pool
      Disconnect and Validation Connection method
    • @ValidateConnection : Invoked before the invocation of an operatio


  • To read the property files keys you need to put the property file under the folder src/main/resources and then in the flow file you have to add an entry 
    • <context:property-placeholder location=""/>
    • xmlns:context="" 
  • You can read the attribute like ${host} in the flow file.

  • To read the http POST parameter you have to have the following entry in the flow file.

Flow XML


  • Connector Compilation : Go the the directory where the mule project is reside and run the following command to compile the connector. If the compilataion is success it will create a target folder under the mule project. This target folder intern have myconnector-1.0-javadoc.jar and files which contains  the documentation and the connector to export. The first command will generate the document but there are some missing element. If you want to resove this you have to run the second command. Second command will generate the document in apidocs folder under the target folder and not in the myconnector-1.0-javadoc.jar file.

    • mvn3 clean package -e

    • mvn3 javadoc:javadoc

  • Importing third party library : If you want to import the third party jar then you have to run the following commands

    •  mvn install:install-file -Dfile=/home/username/jdbc.jar -DgroupId=org.mule.modules -DartifactId=myconnector -Dversion=1.0 -Dpackaging=jar

    • mvn install:install-file -Dfile=/home/username/jdbc.jar -DgroupId=org.test -DartifactId=myconnector -Dversion=1.0 -Dpackaging=jar

  • Mule ESB / Mulesoft express deployment as Tomcat service

    • Download Mule standalone.
    • Unpack it in the server’s location of your desire. 
    • Place your zipped Mule application in the /mule-standalone/apps directory.
    • If you have any kind of connector .jar, place it in the /mule-standalone/lib/mule directory.
    • Now you’re ready to run your application, go to  /mule-standalone/bin and you can do ./mule
    • And stopping it using Crtl-C.
    • Or you can manipulate it as a daemon using instead mule start/stop/restart

No comments:

Post a Comment