Over a million developers have joined DZone.

How to write a custom dispatcher for WSO2 ESB

Is iPaaS solving the right problems? Not knowing the fundamental difference between iPaaS and dPaaS could cost you down the road. Brought to you in partnership with Liaison Technologies.

Create a maven project and add the following dependencies to the pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>Custom_Dispatcher</groupId>
    <artifactId>CustomDispatcher</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.apache.synapse</groupId>
            <artifactId>synapse-core</artifactId>
            <version>2.1.0-wso2v5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.synapse</groupId>
            <artifactId>synapse-extensions</artifactId>
            <version>2.1.0-wso2v5</version>
        </dependency>
    </dependencies>
</project>
The new dispatcher will be 'CustomDispatcher'.

Write your own dispatcher (Get an idea about the CustomURIBasedDispatcher.java )
https://svn.wso2.com/wso2/custom/projects/projects/carbon/3.2.3/trunk/dependencies/synapse/2.1.0-wso2v5/modules/core/src/main/java/org/apache/synapse/core/axis2/CustomURIBasedDispatcher.java

Copy it to [WSO2_ESB_Installation]/repository/components/lib and restart ESB.

Include the following in the axis2.xml. It should be inserted into the dispatch phase of the In-Flow of the ESB. It should be the first handler in the Dispatch phase.
<handler name="CustomDispatcher"
 class="com.wso2.Dispatcher.CustomDispatcher"/>

Discover the unprecedented possibilities and challenges, created by today’s fast paced data climate and why your current integration solution is not enough, brought to you in partnership with Liaison Technologies.

Topics:

Published at DZone with permission of Achala Chathuranga Aponso, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}