While working with Business Events (BEs), I faced some issues. In this blog, I am documenting whatever I did to successfully raise BEs.
I have divided this blog into 3 sections:
- Setup Required for BEs.
- Code Development.
- Deployment and Running the application to raise BEs.
For this example, I have used two servers:
- JDev's Integrated WLS (IWLS) for ADF application that raises the BE.
- Standalone SOA Server - Separate server where SOA application ( that will consume the BE raised by ADF app ) will be deployed.
Both the server are using my local Oracle Database for EDN. So, same EDN is shared by both the servers.
Hence, you can deploy each application on separate servers.
Setup Required for BEs.
Download and install SOA extension on JDev so that IWLS will have the libraries required for BE. Specifically, 'oracle.soa.workflow.wc'. To download SOA extension, go to Help->Check For Updates:
Do not uncheck 'Oracle Fusion Middleware Products' & 'Official Oracle Extensions and Updates', and click Next.
Select SOA extension and click Finish. Since I have already done it, so my JDev is not showing that entry now so can't add that snapshot.
The SOA extension will take some time to download. Once that is done, start the server, and in the IWLS console, you will be able to see an entry for 'oracle.soa.workflow.wc' library in the Deployments page.
Without this library, while raising BEs, you will get the following error:
<Utils> <buildFacesMessage> ADF: Adding the following JSF error message: oracle/fabric/blocks/event/BusinessEventConnectionFactory
. . .
Caused by: java.lang.ClassNotFoundException: oracle.fabric.blocks.event.BusinessEventConnectionFactory
... 65 more
By installing SOA extenstion to JDev, we can use JDev's IWLS to raise events successfully.
Apart from this, you need to create the following two Data Sources(DSs) on IWLS:
- EDNDataSource (XA DS )
- EDNLocalTxDataSource (Non-XA DS)
If you don't define these DSs, you will get the following messages in JDev log while raising BEs:
INFO: Looking for BusinessEventConnectionFactory
INFO: Looking for EDN-DB JNDI configuration to create SAQRemoteBusinessEventConnectionFactory.
INFO: Unable to create SAQRemoteBusinessEventConnectionFactory: [jdbc/EDNSource or jdbc/EDNDataSource] undefined.
INFO: Looking for EDN-JMS JNDI configuration to gcreate JMSRemoteBusinessEventConnectionFactory.
INFO: Unable to create JMSRemoteBusinessEventConnectionFactory: [java:comp/UserTransaction] undefined.
INFO: Unable to create JMSRemoteBusinessEventConnectionFactory: [jms/fabric/EDNConnectionFactory] undefined.
INFO: Failed to get ConnectionFactory instance.
. . .
<JmsBusinessEventBusMessages> <warnUsingGlobalDatasourecForLocal> Local Tx Datasource not found, using XA datasource. Please update your configuration.
Once you define these DSs successfully, you wont get these messages in JDev log, and are required for successfully raising BEs.
EDNSource is not required if you define EDNDataSource. Looks like ENDSource is an old name of the driver and the new name is EDNDataSource.
In my case, SOA Server is already having these DSs, so I just replicated those DSs on IWLS.
For more details about DSs, please refer to the following forum post:
I have created a small application over SCOTT.EMP table to raise a BE on employee creation.
EmpEO is based on SCOTT.EMP, and added to AppModule through EmpVO. Using the Business Events section of EmpEO, I defined and published the following event:
The following is the event definition:
After that, I created a simple page for EmpVO, and added two buttons, one for row insertion, and second one for commit:
Then, in the weblogic-application.xml, visible in Descriptors->META-INF folder in Application Resources, I added the following entry:
This is done so that we can get access to 'oracle.fabric.blocks.event.BusinessEventConnectionFactory'.
If we straight away add 'SOA Runtime' or 'SOA Workflow' library to our model project, some how the class is not accessible, so getting this from the server itself.
Then created a small SOA application to subscribe to the event using Mediator, and writing the payload to a text file using a File Adapter:
The Mediator in the above figure points to the EmpEO.edl and EmpEO.xsd files of the previously created ADF application. The mediator passes the payload to BPEL:
The following image shows the structure of BPEL, which transfers to payload to File Adapter:
And File Adapter writes the paylaod to a file in C:\TEMP folder:
Using the EmpEOs schema:
So, now lets run the application to raise BEs.
Deployment and Running the application to raise BEs.
Deploy the SOA application to the standalone SOA Server:
And run the ADF Application using CreateEmployee.jspx. Click 'CreateInsert' to insert a row in the table as shown below:
After entering the data, Click Commit. The BE is raised, and you can confirm by querying 'AQ$EDN_EVENT_QUEUE_TABLE' view:
If there is a consumer, like SOA app in our case, the records get vanished after a min or so, and SOA app writes the following paylaod to a text file as expected: