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
Your correct m8, the reporting action rules but the default JMS reporting provider sucks big time (since the early ALSB days).
ReplyDeleteUnderstanding the OSB Report action: http://jvzoggel.wordpress.com/2012/01/18/osb_tracing_report_action/
Creating a custom report provider:
http://jvzoggel.wordpress.com/2012/02/15/oracle-service-bus-logging-tracing-iii-create-custom-report-provider/
Indeed Jan,
DeleteGreat blogs by the way.
Hi Edwin,
ReplyDeleteGreat blog!! But i am getting an issue while using your source code:
javax.ejb.EJBTransactionRolledbackException: EJB Exception: ; nested exception is: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
Error Code: 942
Call: SELECT ID, CONVERSATION_IDENTIFIER, MESSAGE_DATE, MESSAGE_TYPE, RECEIVER, SENDER, STATE FROM MESSAGE WHERE (CONVERSATION_IDENTIFIER = ?)
bind => [1 parameter bound]
Can you please help with this?
Hi,
DeleteDid you manually create these tables, I didn't enable this ( you can change the JPA property ) or maybe the used datasource is not there or pointing to the wrong schema.
Thanks
I have few questions-:
DeleteWhile executing your code every time I am getting value of "REPORTINGDATATYPE" is 2.
So what is "REPORTINGDATATYPE"? What is the use of "REPORTINGDATATYPE"?
Please explain...