Deploy your AQ , DB or JMS Resource Adapter to Weblogic and use it in OSB & SOA Suite

Bookmark and Share
When you are familiar with SOA Suite 11g or Oracle Service Bus then you know, that sometimes you need to configure some Resource Adapters in WebLogic. This is necessary when you use the Database, AQ , JMS or Applications adapter in your Composite application or Proxy / Business Service. This task can't be scripted with WLST, The first time you need to generate a Deployment Plan and after that, you can add your EIS entries. In a Cluster environment you need to put this Deployment Plan on a shared storage or copy this to every server.

In this blogpost I will you show that you can deploy your own Resource Adapter with your EIS entries to the SOA Server or Cluster. This way you can separate EIS entries in their own Resource Adapter, so you don't have one big Deployment Plan. Reduce the human factor and just deploy it, no manual tasks after you SOA Composites deployments. And you can deploy it to a cluster and add these Resource Adapter files to your Subversion system.



Basically I do the following steps.

  • Extract the WebLogic Resource Adapters files to a local folder
  • Remove the jars, because these jars are already loaded in the original Resource Adapters
  • Edit the weblogic-ra.xml and remove the default entries and add your own
  • Pack the Resource Adapter
  • Undeploy the Resource Adapter on the WebLogic Server
  • Deploy the Resource Adapter
  • Set the deployment order after the original Resource Adapter
Here a picture of my JDeveloper project where I can do these tasks with the help of ANT and WLST.

 To make this work you need to add your WebLogic jar to the classpath of the ANT environment.





Change the weblogic-ra.xml with your own Entries.



And at last deploy all the Resource Adapters or just one



Here is the ANT properties file. With changing the EnvironmentName you can create a different set of Resource Adapters

FMW.home=C:/oracle/Soa11gPS2
WLS.home=${FMW.home}/wlserver_10.3
SOA.home=${FMW.home}/Oracle_SOA1
SOA.adapters.home=${SOA.home}/soa/connectors

WLS.fullclient=C:/java/wlfullclient.jar

AQ=AqAdapter
DB=DbAdapter
JMS=JmsAdapter

EnvironmentName=MyAdap

build.folder=build

serverURL=t3://laptopedwin:7001
user=weblogic
password=weblogic1

targets=soa_server1


The ANT Build file

<?xml version="1.0" encoding="UTF-8" ?>
<project default="init">

<property file="build.properties"/>

<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy"/>
<taskdef name="wlst"     classname="weblogic.ant.taskdefs.management.WLSTTask"/>

<target name="initAdapters">
<!-- make an environment folder   -->
<delete dir="${EnvironmentName}" failonerror="true" />
<mkdir  dir="${EnvironmentName}"/>
<!-- unpack the adapters   -->
<unjar src="${SOA.adapters.home}/${AQ}.rar" dest="${EnvironmentName}/${AQ}" />
<unjar src="${SOA.adapters.home}/${DB}.rar" dest="${EnvironmentName}/${DB}" />
<unjar src="${SOA.adapters.home}/${JMS}.rar" dest="${EnvironmentName}/${JMS}" />     
<!-- remove the jars   -->
<delete>
<fileset dir="${EnvironmentName}" includes="**/*.jar"/>
</delete>
</target>

<target name="packAdapters">
<!-- make a build folder   -->
<delete dir="${build.folder}"/>
<mkdir dir="${build.folder}"/>
<jar basedir="${EnvironmentName}/${AQ}" destfile="${build.folder}/${EnvironmentName}_AQAdapter.rar" />
<jar basedir="${EnvironmentName}/${DB}" destfile="${build.folder}/${EnvironmentName}_DBAdapter.rar" />
<jar basedir="${EnvironmentName}/${JMS}" destfile="${build.folder}/${EnvironmentName}_JMSAdapter.rar" />
</target>

<target name="deployAll" depends="packAdapters">
<!-- deploy AQ   -->
<antcall target="deployAQ"/>
<antcall target="deployDB"/>
<antcall target="deployJMS"/>
</target>  

<target name="deployAQ" depends="packAdapters">
<!-- deploy AQ   -->
<antcall target="undeploy" >
<param name="deployment" value="${EnvironmentName}_AQAdapter"/>
</antcall>
<antcall target="deploy" >
<param name="deployment" value="${EnvironmentName}_AQAdapter"/>
</antcall>     
<antcall target="changeDeploymentOrder" >
<param name="deployment" value="${EnvironmentName}_AQAdapter"/>
</antcall>     
</target>  

<target name="deployDB" depends="packAdapters">
<!-- deploy AQ   -->
<antcall target="undeploy" >
<param name="deployment" value="${EnvironmentName}_DBAdapter"/>
</antcall>
<antcall target="deploy" >
<param name="deployment" value="${EnvironmentName}_DBAdapter"/>
</antcall>     
<antcall target="changeDeploymentOrder" >
<param name="deployment" value="${EnvironmentName}_DBAdapter"/>
</antcall>     
</target>  

<target name="deployJMS" depends="packAdapters">
<!-- deploy AQ   -->
<antcall target="undeploy" >
<param name="deployment" value="${EnvironmentName}_JMSAdapter"/>
</antcall>
<antcall target="deploy" >
<param name="deployment" value="${EnvironmentName}_JMSAdapter"/>
</antcall>     
<antcall target="changeDeploymentOrder" >
<param name="deployment" value="${EnvironmentName}_JMSAdapter"/>
</antcall>  
</target>  

<target name="changeDeploymentOrder" >
<wlst failonerror="true" debug="true" arguments="${user} ${password} ${serverURL} ${deployment}">
<script>
adminUser=sys.argv[0]
adminPassword=sys.argv[1]
adminUrl=sys.argv[2]
deploymentAdapter='/AppDeployments/'+sys.argv[3]

connect(adminUser,adminPassword,adminUrl)

edit()
startEdit()

cd(deploymentAdapter)
cmo.setDeploymentOrder(500)

activate()
disconnect()    
</script>
</wlst>

</target>

<target name="undeploy">
<wldeploy action="undeploy" 
name="${deployment}"
user="${user}"
password="${password}"
adminurl="${serverURL}"
targets="${targets}"
failonerror="false">
</wldeploy>
</target>

<target name="deploy">
<wldeploy action="deploy" 
name="${deployment}"
source="${build.folder}/${deployment}.rar"
user="${user}"
password="${password}"
adminurl="${serverURL}"
targets="${targets}"
upload="true"
failonerror="true">
</wldeploy>
</target>



</project>

{ 0 comments... Views All / Send Comment! }

Post a Comment