This section describes the best practices and recommendations you can follow when implementing and using connectors with WSO2 ESB.
Following are some of the best practices you can adhere to when using connectors:
Use secure vault to secure user credentials used in the
init
method. For more information on how to use secure vault, see Working with Passwords.To seamlessly refresh tokens, use a registry location that is visible to all esb cluster members. For example, config registry mounted. Here the refresh token value should be passed as a connector parameter. For detailed information on how this can be done for the relevant WSO2 ESB connectors, see the documentation for the relevant connector.
Use
$ctx
instead of theget-property()
function because$ctx
provides better performance thanget-property()
.
Following are some of the best practices you can adhere to when implementing connectors:
Always use lowercase letters to name a connector. For example, activecampaign.
Make sure that the parameter values are atomic to the calling api. For example, if the api expects the following request to insert the
firstname
andlastname
for a user, you need to provide thefirstname
andlastname
as separate parameters when implementing the connector.Request"user": { "firstname" : "someuser", "lastname" : "someuser", "groups" : [ "jira-users", "my-custom-group" ], "active" : true, "email" : "user1@example.com", "fullname" : "User 1"}
When writing Java based connectors, avoid using class level variables in the messages flow logic.
When writing soap or rest based connectors, always use the call mediator. Also make sure that you provide the functionality to control the blocking behavior inside the connector.
Make
API url
andAPI version
configurable in theinit
method.
For answers to some of the common questions regarding implementing a connector, see the FAQ section.