With the OSB Report Action we can add some tracing and logging to an OSB Proxy, this works OK especially when you add some Report keys for single Proxy projects but when you have projects with many Proxies who are invoking other JMS or Local Proxies than the default reporting tables (WLI_QS_REPORT_DATA, WLI_QS_REPORT_ATTRIBUTE ) in the SOA Suite soainfra schema is not so handy.
I want to introduce a conversation id which will be used in all the Proxies and a unique message id for a proxy which will be used in the request and response. Plus it has a status field for the whole conversation ( default = OK, when there is an error somewhere in the conversation then the status will be ERROR)
With this as result. 2 conversations 1 is OK and all matching detail messages ( every proxy has its own messageId so you know which request, response or error belong to each other )
This way I can build my own application which can display all this data, combine this for example with my ErrorHospital data.
The default JMS Reporting part works great for me, so in my Custom Reporting provider I want to re-use the publishing way of the OSB ReportMessage ObjectMessages in the JMS Queue ( wli.reporting.jmsprovider.queue )
So in the next steps I will create a new EJB Application with a Message Driven Bean who reads this ObjectMessage and pass it on to an EJB Session Bean which will use JPA to persist the data in these two tables.
So the first step is to create a new application in JDeveloper and this listener class to the weblogic-application.xml ( located in the src/meta-inf folder of your workspace )
<listener-class>
com.bea.wli.reporting.jmsprovider.init.JmsReportingStartupAndShutdown
</listener-class>
This will enable the OSB Reporting.
You also need plus you need to untarget the default JMS reporing Provider else both applications tries to read the JMS messages.
Add the following jars to your application and uncheck the Export selection ( they are already there on the osb server ). You can find the com.bea.alsb.reporting.api.jar and com.bea.alsb.reporting.impl.jar in your Oracle_OSB1/lib/modules folder of your middleware home
Create a Message Driven Bean
Next step is to tune this MDB so it runs under the ALSBSystem role (ejb-jar.xml ) and in the weblogic-ejb-jar deployment descriptor I set the max and initial pool to 1, this way I can make sure that I have only 1 message record per conversation Id plus this MDB runs as alsb-system-user user.
Add our two JPA entities ( message and message detail ) to the model project and create an EJB session bean with a local interface. This EJB will be invoked by the MDB and pass on the ReportMessage entity.
In the persistence.xml I will reuse the already created wlsbjmsrpDataSource Datasource ( the message table are also in the soainfra schema )
The EJB session bean does all the heavy work, it needs to determine if the conversation record already exists and retrieve all the Report Action Keys ( message labels).
Click here to see the EJB Session bean https://github.com/biemond/osb11g_examples/blob/master/CustomOSBReporting/JmsReporting/Model/src/nl/amis/mw/reporting/services/OSBReportingSessionEJBBean.java
Last steps is to make on the project level an EJB deployment ( ejb jar ) and add this to Application deployment profile ( ear ), uncheck the export of all the reporting jars and deploy this to the OSB Server ( must deploy from application menu else the listener class is not loaded )
The last step is to add the report action to all our OSB Proxies
We also need a header element in our message body or header where we can store the conversationId and pass on the other Proxies so every report action can use these values as keys.
In every proxy I first need to add the internal OSB proxy messageID to a variable ( and do not pass it on ) I will do this in the first assign.
This way I can use it in the Request and Response Report Action ( So I know which request ,response or error belong to each other).
In the first Report action I also provided some extra data ( like messagetype, sender, receiver) this will also be stored in the message table.
In the other proxies I only need to use the Conversation Id and the messageId of that proxy.
In the Error handler I also added a report action so I know what the error is and set the status of the message to ERROR
That's all for the custom reporting part. Off course you can add extra field to these tables by adding your own report keys. You only need to change the EJB and the JPA Entities.
Here you can find all the code together with an OSB demo workspace.
https://github.com/biemond/osb11g_examples/tree/master/CustomOSBReporting
Tuesday, June 11, 2013
Tuesday, April 30, 2013
Offline Oracle Service Bus Configuration export
With Oracle Service Bus PS6 or 11.1.1.7 we finally have an new offline build tool with does not require Eclipse (OEPE). With this OSB configjar tool ( located in the OSB home /tools/configjar/ folder ) you can make OSB export sbconfig jar based on 1 or more OSB projects or even with more then one OSB Configuration projects. Plus have total control what to include or exclude.
In this blogpost I will show you first, how to do this in a shell script with I run on a linux server and the second part how to do the same with maven.
all demo code is available at github and contains a demo OSB workspace.
First step is to create an configuration setting xml with will be used by the configjar utility
here is an example of a OSB workspace configuration file with all its project and resources
and in this case only one project and an separate export for particular system resource
To see all the possible options see this Oracle document page
Next step is to use this setting xml in our shell script.
That's all, this will generate the sbconfig jars but we can also do the same with maven.
The rest of the blog will describe the maven build and deploy.
First we also need to have a setting xml which will be used by maven. The OSB setting file does not support environment variables so I need to use the com.google.code.maven-replacer-plugin maven plugin to replace the tokens.
This is the workspace setting xml ( located in the OSB workspace folder)
This is de project setting xml ( located in the OSB project folder)
The workspace pom ( located in the OSB workspace folder) , where the path to parent pom is different and the target folder
The OSB project pom ( located in the OSB project folder) , this one is level deeper then the workspace pom.
Here is the parent pom with the prepare package phase to replace the tokens in the osb setting file, package for making a sbconfig jar and the deploy phase which use the WLST import.py script to deploy it to the server.
Last step is to add some variables to the maven settings.xml, which contains all the WebLogic and OSB variables
At last we can generate some artifacts.
. osb.sh ( sets maven, java environment variables )
mvn package, builds all or 1 project depends on the location in the source folder ( OEPE Workspace )
mvn deploy -Dtarget-env=dev-osb, deploy to the dev OSB server
mvn release:prepare, prepare a release
mvn release:perform -Dtarget-env=dev-osb -DconnectionUrl=scm:git:git@github.com:biemond/soa_tools.git
Here is the url of the demo workspace on github
In this blogpost I will show you first, how to do this in a shell script with I run on a linux server and the second part how to do the same with maven.
all demo code is available at github and contains a demo OSB workspace.
First step is to create an configuration setting xml with will be used by the configjar utility
here is an example of a OSB workspace configuration file with all its project and resources
<configjarSettings xmlns="http://www.bea.com/alsb/tools/configjar/config">
<source>
<project dir="/home/oracle/projects/soa_tools/maven_osb_ps6_tool/source/ReliableMessageWS"/>
<project dir="/home/oracle/projects/soa_tools/maven_osb_ps6_tool/source/XSDvalidation"/>
<system dir="/home/oracle/projects/soa_tools/maven_osb_ps6_tool/source/OSB Configuration"/>
</source>
<configjar jar="/home/oracle/projects/soa_tools/maven_osb_ps6_tool/export/sbconfig-resources.jar">
<projectLevel includeSystem="true"/>
</configjar>
</configjarSettings>
and in this case only one project and an separate export for particular system resource
<configjarSettings xmlns="http://www.bea.com/alsb/tools/configjar/config">
<source>
<project dir="/home/oracle/projects/soa_tools/maven_osb_ps6_tool/source/ReliableMessageWS"/>
<system dir="/home/oracle/projects/soa_tools/maven_osb_ps6_tool/source/OSB Configuration"/>
</source>
<configjar jar="/home/oracle/projects/soa_tools/maven_osb_ps6_tool/export/sbconfig-rel.jar">
<projectLevel includeSystem="false"/>
</configjar>
<configjar jar="/home/oracle/projects/soa_tools/maven_osb_ps6_tool/export/sbconfig-rel-system.jar">
<resourceLevel>
<resources>
<include name="**/*.jndi"/>
</resources>
</resourceLevel>
</configjar>
</configjarSettings>
To see all the possible options see this Oracle document page
Next step is to use this setting xml in our shell script.
That's all, this will generate the sbconfig jars but we can also do the same with maven.
The rest of the blog will describe the maven build and deploy.
First we also need to have a setting xml which will be used by maven. The OSB setting file does not support environment variables so I need to use the com.google.code.maven-replacer-plugin maven plugin to replace the tokens.
This is the workspace setting xml ( located in the OSB workspace folder)
<configjarSettings xmlns="http://www.bea.com/alsb/tools/configjar/config">
<source>
<project dir="$WORKSPACE_HOME$/ReliableMessageWS"/>
<project dir="$WORKSPACE_HOME$/XSDvalidation"/>
<system dir="$WORKSPACE_HOME$/OSB Configuration"/>
</source>
<configjar jar="$BUILDDIR$/$ARTIFACTID$-$VERSION$.jar">
<projectLevel includeSystem="$OSBINCLUDESYSTEM$"/>
</configjar>
</configjarSettings>
This is de project setting xml ( located in the OSB project folder)
<configjarSettings xmlns="http://www.bea.com/alsb/tools/configjar/config">
<source>
<project dir="$WORKSPACE_HOME$/ReliableMessageWS"/>
<system dir="$WORKSPACE_HOME$/OSB Configuration"/>
</source>
<configjar jar="$BUILDDIR$/$ARTIFACTID$-$VERSION$.jar">
<projectLevel includeSystem="$OSBINCLUDESYSTEM$"/>
</configjar>
</configjarSettings>
The workspace pom ( located in the OSB workspace folder) , where the path to parent pom is different and the target folder
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>biemond.core.osb</groupId>
<artifactId>tool</artifactId>
<version>1.0</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<groupId>biemond</groupId>
<artifactId>osb.source</artifactId>
<version>1.5.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<buildDirectory>${project.basedir}/../target</buildDirectory>
<buildOsbBase>${project.basedir}/../</buildOsbBase>
<osbProjectBase>${project.basedir}</osbProjectBase>
<osbIncludeSystem>true</osbIncludeSystem>
</properties>
<scm>
<connection>scm:git:git@github.com:biemond/soa_tools.git</connection>
<developerConnection>scm:git:git@github.com:biemond/soa_tools.git</developerConnection>
<url>https://github.com/biemond/soa_tools/tree/master/maven_osb_ps6_tool</url>
<tag>osb.source-1.3.3</tag>
</scm>
</project>
The OSB project pom ( located in the OSB project folder) , this one is level deeper then the workspace pom.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>biemond.core.osb</groupId>
<artifactId>tool</artifactId>
<version>1.0</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
<groupId>biemond</groupId>
<artifactId>osb.source.reliablemessagews</artifactId>
<version>1.4.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<buildDirectory>${project.basedir}/../../target</buildDirectory>
<buildOsbBase>${project.basedir}/../../</buildOsbBase>
<osbProjectBase>${project.basedir}/../</osbProjectBase>
<osbIncludeSystem>true</osbIncludeSystem>
</properties>
<scm>
<connection>scm:git:git@github.com:biemond/soa_tools.git</connection>
<developerConnection>scm:git:git@github.com:biemond/soa_tools.git</developerConnection>
<url>https://github.com/biemond/soa_tools/tree/master/maven_osb_ps6_tool</url>
<tag>HEAD</tag>
</scm>
</project>
Here is the parent pom with the prepare package phase to replace the tokens in the osb setting file, package for making a sbconfig jar and the deploy phase which use the WLST import.py script to deploy it to the server.
Last step is to add some variables to the maven settings.xml, which contains all the WebLogic and OSB variables
At last we can generate some artifacts.
. osb.sh ( sets maven, java environment variables )
mvn package, builds all or 1 project depends on the location in the source folder ( OEPE Workspace )
mvn deploy -Dtarget-env=dev-osb, deploy to the dev OSB server
mvn release:prepare, prepare a release
mvn release:perform -Dtarget-env=dev-osb -DconnectionUrl=scm:git:git@github.com:biemond/soa_tools.git
Here is the url of the demo workspace on github
Tuesday, April 2, 2013
Token Configurations in Oracle SOA Suite PS6 ( 11.1.1.7.0)
Oracle Soa Suite PatchSet 6 or 11.1.1.7.0 now has support for Token configurations which really can help administrators in configuring or overriding external Web Service Reference parameters like the protocol ( http, oramds or https ), the remote host etc. And more important if you do it right you can kick out the all those Soa Suite deployment plans :-)
Important to know this only works on the location attribute of the binding.ws element of the composite.xml file. But when you use Metadata Service (MDS) and call a Web Service like a Java WS, .Net WS, OSB or SOA Suite Reference Services then you can use this new feature.
In this blogpost I will show you all the steps.
First step is to make all these services in depended of each other ( Don't want invalid composites or want to use deployment plans ), I followed this great AIA blog about Best Practices for Decoupling Services and Avoiding Invalid Composites at Server Startup
In this demo I created a workspace with a MDS project which contains some WSDL's with a XML Schema. This WSDL is used in the Helloworld Reference Soa project. Deployed it together with the MDS soa sar and I put the Impl of the Reference WSDL back to the MDS so it can be used in my other main project ( I downloaded it from the EM and changed the xml schema import ).
The main project will call this helloworld reference service and in this project we will use a server name token in the WSDL url ( location attribute of the binding.ws element ).
Select our reference service and click on edit.
Lookup the just created Token file and on the Host field we can lookup our LocalSoaServer entry.
This will change the location attribute to http://${LocalSoaServer}:8001.....
We are ready to compile the project.
The Soa Suite server does not know this LocalSoaServer token so we need to create this token in the Enterprise Manager.
Go to SOA Infrastructure -> SOA Administration -> Token Configurations.

This will update the mdm-url-resolver.xml file located in the config/fmwconfig folder of the weblogic soa domain.
We can also upload the Token file of JDeveloper, this will add the missing tokens.
You need to reboot the Soa Server, after this you can deploy the main project and test the main project.
here is the demo workspace with all the above code.
Important to know this only works on the location attribute of the binding.ws element of the composite.xml file. But when you use Metadata Service (MDS) and call a Web Service like a Java WS, .Net WS, OSB or SOA Suite Reference Services then you can use this new feature.
In this blogpost I will show you all the steps.
First step is to make all these services in depended of each other ( Don't want invalid composites or want to use deployment plans ), I followed this great AIA blog about Best Practices for Decoupling Services and Avoiding Invalid Composites at Server Startup
In this demo I created a workspace with a MDS project which contains some WSDL's with a XML Schema. This WSDL is used in the Helloworld Reference Soa project. Deployed it together with the MDS soa sar and I put the Impl of the Reference WSDL back to the MDS so it can be used in my other main project ( I downloaded it from the EM and changed the xml schema import ).
The main project will call this helloworld reference service and in this project we will use a server name token in the WSDL url ( location attribute of the binding.ws element ).
In my main project I added this externel reference web service to my composite by selecting the Reference Impl from the MDS ( First add a File MDS in the Resource Palette and map this to your local MDS location and finally lookup the WSDL, for compiling you also need to add an extra MDS location to the adf-config.xml )
After adding the reference service, we need to fix some hard references in the composite.xml to this remote service.
- Change the location attribute of the composite import to oramds://
- Do the same for ui:wsdlLocation attribute of the Reference element.
- In the location attribute of the Binding.WS element we need to use the real reference WSDL url ( see the EM for the reference WSDL url ).
Do the same for the Reference Wrapper WSDL
Now our main Soa Suite project only needs this reference service at runtime and we won't have any deployment issues or invalid composites after a reboot of the Soa Suite Service.
Next step is to create a Token file which contains some server host entries, we can use this file in the JDeveloper Token wizard or later when we want to import these Tokens in the Oracle Enterprise Manager. See this url for an Token xml example http://docs.oracle.com/cd/E28280_01/dev.1111/e10224/sca_bindingcomps.htm#CIHFJFJC
I added two host key values entries
Click the token button of the composite.xml editor.
Select our reference service and click on edit.
Lookup the just created Token file and on the Host field we can lookup our LocalSoaServer entry.
This will change the location attribute to http://${LocalSoaServer}:8001.....
We are ready to compile the project.
The Soa Suite server does not know this LocalSoaServer token so we need to create this token in the Enterprise Manager.
Go to SOA Infrastructure -> SOA Administration -> Token Configurations.
Click on Modify Configuration File and add a new token.

Add the LocalSoaServer Token with its value.
Commit this token.
This will update the mdm-url-resolver.xml file located in the config/fmwconfig folder of the weblogic soa domain.
We can also upload the Token file of JDeveloper, this will add the missing tokens.
here is the demo workspace with all the above code.
Subscribe to:
Posts (Atom)























