Monday, November 12, 2012

Supporting Hierarchical Proxy Services

When I was in WSO2 ESB team, I got a change to contribute to ESB product in WSO2. I did an improvement to WSO2 ESB proxy services. Proxy service is an intermediate component between client program and the actual server which the client is seeking for. When a proxy service is deployed at that moment ESB save the configuration file inside ESB_HOME/repository/deployment/server/synapse-configs/default/proxy-services/ directory where all the proxy services are saved. If we deploy a proxy service named “foo” that proxy service will be saved in ESB_HOME/repository/deployment/server/synapse-configs/default/proxy-services/ as foo.xml. The service URL for that proxy service is 8280:services/foo.

Since all the proxy services are deployed under the same directory, it is very hard to manage the services for a large organization when the number of services becomes large, because they have to agree on service name before deploying them. And also supporting multiple versions of the same service is not possible without changing the service name in the services.xml file.

Therefore it was one of the requirements of ESB team to have hierarchical proxy services in WSO2 ESB. My task was to implement hierarchical proxy service in WSO2 ESB. When proxy service is created other than the name, there is an option to give service hierarchy also, but service hierarchy is an optional requirement. If service hierarchy is not given the proxy service XML file will be saved in the default directory. Below figure shows a screen shot of User interface which I created in order to add service hierarchy.





I added a new property called serviceHierarchy to the proxy service configuration when a proxy service is added. Below is the proxy service configuration for adding a proxy service named foo and service hierarchy “a/b/c/”.

     <proxy name="foo"
          serviceHierarchy="a/b/c/"
          transports="https http"
          startOnLoad="true"
          trace="disable">
      <description/>
      <target>
         <endpoint>
            <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
         </endpoint>
      </target>
   </proxy>

After deploying this proxy service, proxy configuration XML file will be saved in ESB_HOME/repository/deployment/server/synapse-configs/default/proxy-services/a/b/c/ directory. If the proxy service is removed from the ESB only the file will be deleted. The directory structure will be remained unchanged, because there will be other proxy files inside those directories.

I mainly did changes in synapse core of the ESB package. When proxy service is created ProxyserviceSerializer class serialize the proxy service as an OMElement. I added “serviceHierarchy” as an attribute of the proxy service. When ESB server starts proxy service is loaded from the OMElement by ProxyserviceFactory. Below figure shows what I described above.






No comments:

Post a Comment