Oracle SOA Suite: further Build and Deployment Automation for Enterprise Service Bus components

1

Some time ago I wrote an article on SOA Suite Build, Deployment and Test Automation. A section of the article was devoted to automating builds and deployments for Oracle Enterprise Service Bus (ESB) components. Not covered was deployment of Services to multiple environments as is usually done throughout the development and test process of a system. This blog post starts where the article stopped: it describes build and deployment automation for an ESB System in a way that it can easily be deployed to multiple environments that support the system development life-cycle.

Support for build automation in SOA Suite

It seems that Oracle has not gone to extremes in providing support for build automation for SOA Suite. Sure, from within JDeveloper it is easy to compile and deploy BPEL and ESB components to diverse environments. But I would love to see Oracle move (further) away from the use of JDeveloper for this purpose as it stands in the way of automating the build, deployment and test process. Oracle should embrace Ant or Maven and make sure that the exact same scripts are used from within JDeveloper as well.
The importance of a streamlined and manageable build and test process is illustrated by the comments on the SOA Suite forum that is hosted on Oracle’s Technology Network. For example, see this thread for ESB deployment automation. And in some cases this even results in a heated debate Smiley.

Setting up a streamlined build and deployment process is of vital importance for any system development effort. This is especially true for a SOA implementation in which you need to ensure that a robust system is constructed from various loosely coupled services. It may require some initial effort and getting used to, but in the end this approach will save you valuable time and help provide your customers with consistently high-quality systems.....

Sample Scenario

For demonstration purposes I have created an extremely simple scenario: an ESB System takes in a text string that it passes on to a synchronous BPEL Process. The BPEL Process and the ESB System do not manipulate the text; in fact, nowhere in this scenario is any intelligence to be detected. The following picture provides an overview of the BPEL Process:

Hello World BPEL Process 

 

And here is the equally simple ESB System that does no more than route the message to the BPEL Process:

The default XML schema that is used for the BPEL process is also used as input for the ESB Routing Service that is defined in the ESB System:

ESB Routing Service based on same XSD as BPEL Process

 

Use WSDL URL’s and ESB SOAP Services as the target for the ESB System

Note that the HelloWorld BPEL Process that is the target Service in the ESB System was not selected using the ‘Browse Target Service Operation’ dialog in JDeveloper that is shown in the following screenshot:

 

Constructing the ESB System that way would have resulted in the following picture of the ESB System. Notice the subtle difference in comparison to the overview picture that was appeared earlier:

Hello World ESB System using Browse Target
And there are more differences below the surface, e.g. in the generated .esbsvc file for the Service. Using the browser for defining the target service makes us run into deployment problems as well as runtime issues; hence we refrain from doing that. We always use the WSDL URL for the intended target service and create a SOAP Service in the ESB Designer as shown in the following screen shot:

 

SOAP Service specification for Target Service

 

Build and Deployment Automation prerequisites

Oracle’s Doug Gschwind created a badly needed Ant extension that supports build and deployment automation for ESB Systems. It may be downloaded from OTN. The approach outlined here builds on Doug’s work.
First job is to install Doug’s Ant extension. Check the included manual and the OTN Forums for assistance if required. We use Ant 1.7 for running it. An Ant build script has to be added to every ESB System. Place it in the ESB Project’s directory. The template we use in our projects is shown later. It must be adapted to contain the global unique identifiers (or guids) for the artifacts in the ESB System. This will only take a few minutes.

Build and Deployment Process Steps

With the Ant extension and the build.xml script in place the deployment process for an ESB System involves the following steps:

  1. Deploy the ESB System in an environment of your choice. An initial deployment is required in order to generate a Deployment Plan. Typically, the development environment is used for this purpose.
  2. Adapt the Deployment Plan for deploying the ESB System to any other environments that support the system development life-cycle. Essentially, this means changing the WSDL URL’s so that these match up with the environment-specific Service URL’s.
  3. Use the adapted Deployment Plan to roll out the ESB System to the environment of choice.

As we will see, these steps can be highly automated so that deployment of an ESB System to any environment is reduced to a single command.

The Ant Script for Automating the Process

Without further ado, here is the Ant build.xml script that we add to ESB Systems:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot; ?&gt;<br />&lt;project name=&quot;ESBDeploymentProject&quot; default=&quot;usage&quot;&gt;<br /><br />&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - Properties<br />   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;<br /><br />   &lt;property environment=&quot;env&quot;/&gt;<br />   &lt;property name=&quot;esbProjectToDeploy&quot; value=&quot;${basedir}&quot;/&gt;<br />   &lt;property name=&quot;deploymentPlanFilename&quot; value=&quot;${esbProjectToDeploy}/deploymentPlan.xml&quot;/&gt;<br />   &lt;property name=&quot;targetDeploymentPlanFilename&quot; value=&quot;${esbProjectToDeploy}/targetDeploymentPlan.xml&quot;/&gt;<br /><br />&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - Environment specific properties<br />   - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - --&gt;<br />   &lt
;property file=&quot;${env.SOA_DA_HOME}/environment.${param.target.env}.properties&quot; /&gt;<br /><br />   &lt;target name=&quot;param-target-chk&quot; unless=&quot;param.target.env&quot;&gt;<br />     &lt;fail message=&quot;Target deployment environment parameter not set&quot; /&gt;<br />   &lt;/target&gt;<br />   <br />&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - Import, to enable the custom ESB Metadata Deployment ant tasks ...<br />   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;<br /><br />    &lt;import file=&quot;${env.SOA_DA_HOME}/lib/ESBMetadataMigrationTaskdefs.xml&quot;/&gt;<br /><br />&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - ESB Deployment Automation<br />   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;<br /><br />    &lt;target name=&quot;DeployESBProject&quot; depends=&quot;param-target-chk&quot;&gt;<br />      &lt;deployESBProjects<br />	    esbMetadataServerHostname=&quot;${soa.suite.hostname}&quot;<br />		esbMetadataServerPort=&quot;${soa.suite.port}&quot;<br />        userName=&quot;${soa.suite.admin.username}&quot;<br />        password=&quot;${soa.suite.admin.password}&quot;<br />	  &gt;<br />	  &lt;esbProject directory=&quot;${basedir}&quot;/&gt;<br />	  &lt;/deployESBProjects&gt;<br />    &lt;/target&gt;<br /><br />&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - List the GUID's for the UndeployESBEntities target e.g.:<br />	    &lt;system guid=&quot;8D61C3F0871111DB8F2675C60E6C31C6&quot;/&gt;<br />	    &lt;serviceGroup guid=&quot;0EB5F380896111DBBFBC9530C01627AC&quot;/&gt;<br />	    &lt;service guid=&quot;0547F370841611DBBFCF2D9BF80323FA&quot;/&gt;<br />	    &lt;serviceGroup guid=&quot;B90E6B70895F11DBAF1483EEF470B835&quot;/&gt;<br />	    &lt;system guid=&quot;A62C91C1841511DBBFCF2D9BF80323FA&quot;/&gt;<br />- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;<br /><br />    &lt;target name=&quot;UndeployESBEntities&quot; depends=&quot;param-target-chk&quot;&gt;<br />      &lt;undeployESBEntities<br />	    esbMetadataServerHostname=&quot;${soa.suite.hostname}&quot;<br />		esbMetadataServerPort=&quot;${soa.suite.port}&quot;<br />        userName=&quot;${soa.suite.admin.username}&quot;<br />        password=&quot;${soa.suite.admin.password}&quot;<br />	  &gt;<br />	    <strong>&lt;system guid=&quot;AF254B90559411DCBF88696C2BB1E7B8&quot;/&gt;</strong><br />	    <strong>&lt;service guid=&quot;25E5FDB0559511DCBF88696C2BB1E7B8&quot;/&gt;</strong><br />	    <strong>&lt;service guid=&quot;F5A618A0559A11DCBFBF4119724B0CE3&quot;/&gt;</strong><br />	  &lt;/undeployESBEntities&gt;<br />    &lt;/target&gt;<br /><br />&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - Metadata Promotion to different ESB Metadata Servers (environments)<br />   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;<br /><br />    &lt;target name=&quot;ExtractESBDeploymentPlan&quot;&gt;<br />        &lt;delete file=&quot;${deploymentPlanFilename}&quot; verbose=&quot;true&quot;/&gt;<br />        &lt;extractESBDeploymentPlan<br />           sourceDir=&quot;${basedir}&quot;<br />           deploymentPlanFile=&quot;${deploymentPlanFilename}&quot;/&gt;<br />    &lt;/target&gt;<br /><br />    &lt;target name=&quot;ModifyESBDeploymentPlan&quot; depends=&quot;param-target-chk&quot;&gt;<br />      &lt;xmltask source=&quot;${deploymentPlanFilename}&quot; dest=&quot;${targetDeploymentPlanFilename}&quot;&gt;<br />        &lt;replace path=&quot;/deploymentPlan/systemDeploymentPlan/properties/property[@name = 'Host']/@value&quot; withText=&quot;${soa.suite.hostname}&quot; /&gt;<br />        &lt;replace path=&quot;/deploymentPlan/systemDeploymentPlan/properties/property[@name = 'Port']/@value&quot; withText=&quot;${soa.suite.port}&quot; /&gt;<br />      &lt;/xmltask&gt;<br />      &lt;replaceregexp file=&quot;${targetDeploymentPlanFilename}&quot;<br />	                 match=&quot;http://[^/]*/&quot;<br />	                 replace=&quot;http://${soa.suite.hostname}:${soa.suite.port}/&quot;<br />                     byline=&quot;true&quot; /&gt;<br />    &lt;/target&gt;<br /><br />    &lt;target name=&quot;DeployESBSuitcase&quot;<br />	        depends=&quot;param-target-chk, ExtractESBDeploymentPlan, ModifyESBDeploymentPlan, UndeployESBEntities&quot;&gt;<br />      &lt;deployESBSuitcase<br />        esbMetadataServerHostname=&quot;${soa.suite.hostname}&quot;<br />        esbMetadataServerPort=&quot;${soa.suite.port}&quot;<br />        sourceDirectory=&quot;${basedir}&quot;<br />        deploymentPlanFilename=&quot;${targetDeploymentPlanFilename}&quot;<br />        forcedDeployment=&quot;false&quot;/&gt;<br />    &lt;/target&gt;<br /><br />&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - Usage<br />   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;<br /><br />    &lt;target name=&quot;usage&quot;&gt;<br />      &lt;echo&gt;<br />========   Environment   =====================================================<br />  SOA_DA_HOME      = ${env.SOA_DA_HOME}<br />  CLASSPATH        = ${env.CLASSPATH}<br />  ANT_HOME         = ${env.ANT_HOME}<br />========   Properties    =====================================================<br />  basedir          = ${basedir}<br />  SOA Suite server = ${soa.suite.hostname}:${soa.suite.port}<br />  OC4J instance    = ${soa.suite.oc4j.instancename}<br />==============================================================================<br />      &lt;/echo&gt;<br />	  &lt;exec executable=&quot;ant&quot; dir=&quot;${basedir}&quot; vmlauncher=&quot;false&quot;&gt;<br />	    &lt;arg value=&quot;-projecthelp&quot;/&gt;<br />	  &lt;/exec&gt;<br />    &lt;/target&gt;<br /><br />&lt;/project&gt;<br />&nbsp;

The only change to make this template work for the ESB System from the scenario was to look up the guid’s for the System and the Services in the project and put them in the proper place, as indicated in bold.

Note that the build and deployment process is environment specific:

  • We check if the parameter ‘param.target.env’ is set.
  • We use a set of environment-specific properties files (environment.${param.target.env}.properties) to drive ESB and BPEL deployments alike.

Running the DeployESBSuitcase target performs the following tasks for deploying the ESB System to the target environment:

  • First the Deployment Plan is extracted.
  • Subsequently the Deployment Plan is modified for the specific target environment using the ModifyESBDeploymentPlan target.
  • Any existing installation of the ESB System in the target environment is removed by executing the UndeployESBEntities target in order to ensure a clean install.

Modifying the Deployment Plan

The generated Deployment Plan for this service looks like this:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;<br />&lt;deploymentPlan&gt;<br />    &lt;systemDeploymentPlan qname=&quot;HelloWorldESB&quot;&gt;<br />        &lt;properties&gt;<br />            &lt;property value=&quot;&quot; name=&quot;Fax&quot;/&gt;<br />            &lt;property value=&quot;&quot; name=&quot;Mobile&quot;/&gt;<br />            &lt;property value=&quot;soa10133-vm&quot; name=&quot;Host&quot;/&gt;<br />            &lt;property value=&quot;&quot; name=&quot;Phone&quot;/&gt;<br />            &lt;property value=&quot;&quot; name=&quot;Pager&quot;/&gt;<br />            &lt;property value=&quot;&quot; name=&quot;Email&quot;/&gt;<br />            &lt;property value=&quot;80&quot; name=&quot;Port&quot;/&gt;<br />        &lt;/properties&gt;<br />        &lt;serviceDeploymentPlan qname=&quot;HelloWorldESB.HelloWorldBPEL&quot;&gt;<br />            &lt;parent type=&quot;system&quot; qname=&quot;HelloWorldESB&quot;/&gt;<br />            &lt;properties&gt;<br />                &lt;serviceDefinition&gt;<br />
      &lt;property value=&quot;http://soa10133-vm/orabpel/default/HelloWorld/1.0/HelloWorld?wsdl&quot; name=&quot;wsdlURL&quot;/&gt;<br />                    &lt;property value=&quot;http://soa10133-vm:80/event/HelloWorldESB/HelloWorldBPEL&quot; name=&quot;soapEndpointURI&quot;/&gt;<br />                &lt;/serviceDefinition&gt;<br />            &lt;/properties&gt;<br />        &lt;/serviceDeploymentPlan&gt;<br />        &lt;serviceDeploymentPlan qname=&quot;HelloWorldESB.HelloWorldRS&quot;&gt;<br />            &lt;parent type=&quot;system&quot; qname=&quot;HelloWorldESB&quot;/&gt;<br />            &lt;properties&gt;<br />                &lt;serviceDefinition&gt;<br />                    &lt;property value=&quot;HelloWorldESB_HelloWorldRS.wsdl&quot; name=&quot;wsdlURL&quot;/&gt;<br />                &lt;/serviceDefinition&gt;<br />            &lt;/properties&gt;<br />        &lt;/serviceDeploymentPlan&gt;<br />    &lt;/systemDeploymentPlan&gt;<br />&lt;/deploymentPlan&gt;<br />

 

We added the ModifyESBDeploymentPlan target to the build.xml file for modifying this Deployment Plan in order to turn it into an environment-specific one. Benefiting from the well-formed XML file the Deployment Plan is, we use the XMLTask Ant extension for changing the Host and Port properties. Moreover, we apply a regular expression for making the WSDL URL of Services environment specific. The regular expression "http://[^/]*/" that we use for matching looks for any pattern between "http://" and the first forward slash that follows. This can be changed into something less generic if everyone in the project sticks to a standard like "http://host.domain:9700/".

We added the XMLTask task definition to the ESBMetadataMigrationTaskdefs.xml file that is provided in Doug’s original package to make it look like this:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot; ?&gt;<br /><br />&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - The import of this ant build file, by another ant build file, enables the<br />   - use of the custom ant tasks present in ESBMetadataMigration.jar<br />   - Doug Gschwind<br />   - 12 Dec 2006<br />   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;<br /><br />&lt;project name=&quot;ESBMetadataMigrationTaskdefs&quot;&gt;<br /><br />&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - PROPERTIES, Subject to the installation environment<br />   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;<br /><br />    &lt;property environment=&quot;env&quot;/&gt;<br /><br />&lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - Custom ant task definitions, to enable import.<br />   - This section should be treated as immutable upon installation.<br />   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;<br /><br />    &lt;dirname property=&quot;imported.basedir&quot; file=&quot;${ant.file.ESBMetadataMigrationTaskdefs}&quot;/&gt;<br /><br />    &lt;taskdef resource=&quot;oracle/tip/esb/client/anttasks/antlib.xml&quot;&gt;<br />        &lt;classpath&gt;<br />            &lt;pathelement location=&quot;${imported.basedir}/ESBMetadataMigration.jar&quot;/&gt;<br />            &lt;pathelement location=&quot;${env.SOA_DA_HOME}/lib/commons-httpclient-3.0.1.jar&quot;/&gt;<br />            &lt;pathelement location=&quot;${env.SOA_DA_HOME}/lib/xmlparserv2.jar&quot;/&gt;<br />            &lt;pathelement location=&quot;${env.SOA_DA_HOME}/lib/commons-logging.jar&quot;/&gt;<br />            &lt;pathelement location=&quot;${env.SOA_DA_HOME}/lib/commons-codec-1.3.jar&quot;/&gt;<br />            &lt;pathelement location=&quot;${env.SOA_DA_HOME}/lib/oraesb.jar&quot;/&gt;<br />            &lt;pathelement location=&quot;${env.SOA_DA_HOME}/lib/activation.jar&quot;/&gt;<br />            &lt;pathelement location=&quot;${env.SOA_DA_HOME}/lib/jaxb-api.jar&quot;/&gt;<br />            &lt;pathelement location=&quot;${env.SOA_DA_HOME}/lib/jsr173_1.0_api.jar&quot;/&gt;<br />            &lt;pathelement location=&quot;${env.SOA_DA_HOME}/lib/jaxb-impl.jar&quot;/&gt;<br />        &lt;/classpath&gt;<br />    &lt;/taskdef&gt;<br />    <br />    &lt;!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<br />   - Define Ant XML Task for manipulation of the deploymentPlan file<br />   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --&gt;<br />    &lt;taskdef name=&quot;xmltask&quot; classname=&quot;com.oopsconsultancy.xmltask.ant.XmlTask&quot;&gt;<br />      &lt;classpath&gt;<br />         &lt;pathelement location=&quot;${env.SOA_DA_HOME}\lib\xmltask-v1.15.1.jar&quot;/&gt;<br />      &lt;/classpath&gt;<br />    &lt;/taskdef&gt;<br /><br />&lt;/project&gt;<br />

 

Enjoy building and deploying Oracle SOA Suite ESB Services!

Share.

About Author

1 Comment

  1. I’m problem in deploy Ant ESB’s

    These look something like:
    esb:///ESB_Projects/temp_FolderApp_NameService_nameServerXX/ServiceRS.wsdl

    You’d like help to cut ” temp_” and “_nameServerXX”

    Thanks,

    Carmo
    carmomelo@gmail.com