Apps To Fusion

.......Our Journey from Apps To Fusion

 
  • Increase font size
  • Default font size
  • Decrease font size
We have launched several Development, Functional and DBA Trainings. Visiti http://focusthread.com/training

Raising Business Event from PL/SQL or Java Layer

Following are the questions can often come to mind when dealing with Business Event Subscriptions
1. What is the difference between raising a business event from PL/SQL or from Java
2. Why you should not raise a Business Event from OA Framework using a JDBC call to "wf_event.raise"
3. The subscription does not fire in real time, even though business subscription phase is less than 99

Let us deal with these questions one by one.



What is the difference between raising a business event from PL/SQL or from Java
When a business event is raised, effectively a message is placed into an Advanced Queue Table in Oracle. For simplicity assume the there are just two tables i.e.WF_DEFERRED and WF_JAVA_DEFERRED. In reality there are other tables as well to manage the lifecycle of processing the messages in WF Queue. The Advanced Queue table WF_DEFERRED is populated when the Business Event is raised via PL/SQL. However table WF_JAVA_DEFERRED is populated when the business event is raised from Java Layer, for example from OA Framework Page. Population of these tables is also called Enqueuing of the message.




Why do we need two different layers for Business Event processing?
I would answer this within the realms of next question- as below




Why you must never raise a Business Event from OA Framework using a JDBC call to "wf_event.raise"
In theory, and also in practice[call it bad practice]- you can raise a business event into PL/SQL layer from OA Framework page. This can be done if OAF code gets a handle to jdbc connection object and executes WF_EVENT.RAISE. We know that when an OA Framework page is submitted with some data being modified, then Entity Object cache gets populated. During the Entity Object cache population Entity Object methods like validateEntity() are executed.
  Let us assume that you have done the following-
    a. In OA Framework page, you have raised a business event from validateEntity() by getting
        handle to Database Connection and invoking PL/SQL procedure WF_EVENT.RAISE
    b. The business event being raised has a PL/SQL subscription with phase less than 99, i.e. to be executed in real-time
    c. The PL/SQL subscription queries the data on the table which is being updated by the OAF screen/UI itself
        In the example above, the PL/SQL code that queries the tables might not get any data returned, because
        the data is still in Entity Object Cache encapsulated by Application Module.
Therefore, even though it is possible to raise business events into PL/SQL layer from OA Framework, yet it is not recommended to follow this approach. For this very reason, you should use "oracle.apps.fnd.wf.bes.BusinessEvent.raise()" when raising business events from Java Layer.




The subscription does not fire in real time, even though business subscription phase is less than 99
Let us take a scenario. Let us assume you wish to invoke a webservice from PL/SQL Procedure. Of course you can raise Business Events directly from PL/SQL, but that has some limitations, for example 10g DB does not support BLOBS being passed into Web Service when Web Service is called from PL/SQL.
Therefore, for simplicity, you can do the following
    a. From your PL/SQL procedure, raise a business event using WF_EVENT.RAISE
    b. Subscribe a web service or a Java Function to the business event
    c. You keep the phase of this subscription less than 99, so that it gets invoked in real time
In this example, you will notice that even though your phase is lower than 99, the WebService is still being invoked in Deferred Mode.
As a thumbrule, you must remember that whenever you switch the context from PL/SQL to Java in Business Event, then subscription never gets processed in real time. In other words, the only way to invoke WebService or Java Code in real-time from Business Event is by raising the Business Event from java layer.


The image below shows that you can simulate raising the business event from either Java Layer or from PL/SQL Layer, by using "Test Business Event feature"

 

Comments (2)add
...
written by khan , February 02, 2010
Hi Anill,

Thanks for nice blog, In the screenshot show above the two buttons dont appear when i try to go to the this screen.
Regards
Khan
report abuse
vote down
vote up
Votes: +0
...
written by khan , February 02, 2010
Hi Anil,
Sorry did not mention the two buttons name (Raise in Java, Raise in PL/SQL).
How to make them appear.
THanks & Regards,
khan
report abuse
vote down
vote up
Votes: +0
Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

security image
Write the displayed characters


busy