Saturday, September 3, 2011

Business Events Support In Case Of Composition Scenarios

This blog is in continuation of my previous blog:
http://adfblogs.blogspot.com/2011/08/adf-integration-with-soa-1-business.html

The following is what Dev Guide says about composition scenarios:

To support composition scenarios (such as a purchase order with line items), a child entity can raise events defined on the parent entity, and events defined on the child entity can include attributes from the parent entity. When a child entity raises an event on a parent entity, only a single event is raised for a particular top-level entity  per transaction, regardless of how many times the child entity raises it.

So, we can't have a single payload which contains all the data for child and parent entities.
However, from a transaction point of view, all the changes are handled in one transaction.
For details, refer to forum post:

https://forums.oracle.com/forums/message.jspa?messageID=9838631#9838631

Here is how I tested the composition scenario.

I have used SCOTT.EMP and SCOTT.DEPT tables where DEPT is the master table, and created the model project as shown below:





Defined and published a Department update event as shown below:




Defined a create event on Employee entity, and included Department attributes in the event definition, as shown below:




Here is how EmpEO looks like after the changes:




Then, created a new page, BusinessEventTest.jspx and dragged both Emp and Dept VOs to create tables, as shown below:




After running, the page looks like this:


Then, updated the location of first Department record, and created 2 new Employee records, as shown below:



After commit, ran the following query and figured out that business events are raised successfully:

SELECT * FROM AQ$EDN_EVENT_QUEUE_TABLE;

The above query returns 6 records, which means that 3 events are raised, 1 for Department update, and 2 other for each Employee record. To see the payload of each event without consuming the event in SOA composite, you can run the following query that returns 3 record (one for each event):

SELECT E.USER_DATA.EVENT.PAYLOAD FROM EDN_EVENT_QUEUE_TABLE E;

The above query is composed because of the following data model:

CREATE TABLE EDN_EVENT_QUEUE_TABLE (
  Q_NAME            VARCHAR2(30)   NULL,
  MSGID             RAW(16)        NOT NULL,
  CORRID            VARCHAR2(128)  NULL,
  PRIORITY          NUMBER         NULL,
  STATE             NUMBER         NULL,
  "DELAY"           TIMESTAMP(6)   NULL,
  EXPIRATION        NUMBER         NULL,
  TIME_MANAGER_INFO TIMESTAMP(6)   NULL,
  LOCAL_ORDER_NO    NUMBER         NULL,
  CHAIN_NO          NUMBER         NULL,
  CSCN              NUMBER         NULL,
  DSCN              NUMBER         NULL,
  ENQ_TIME          TIMESTAMP(6)   NULL,
  ENQ_UID           VARCHAR2(30)   NULL,
  ENQ_TID           VARCHAR2(30)   NULL,
  DEQ_TIME          TIMESTAMP(6)   NULL,
  DEQ_UID           VARCHAR2(30)   NULL,
  DEQ_TID           VARCHAR2(30)   NULL,
  RETRY_COUNT       NUMBER         NULL,
  EXCEPTION_QSCHEMA VARCHAR2(30)   NULL,
  EXCEPTION_QUEUE   VARCHAR2(30)   NULL,
  STEP_NO           NUMBER         NULL,
  RECIPIENT_KEY     NUMBER         NULL,
  DEQUEUE_MSGID     RAW(16)        NULL,
  SENDER_NAME       VARCHAR2(30)   NULL,
  SENDER_ADDRESS    VARCHAR2(1024) NULL,
  SENDER_PROTOCOL   NUMBER         NULL,
  USER_DATA         EDN_EVENT_DATA NULL,
  USER_PROP         ANYDATA        NULL
);

CREATE OR REPLACE TYPE EDN_EVENT_DATA AS OBJECT (
    EVENT EDN_BUSINESS_EVENT,
    PUBLISH_IMPL CHAR,
    SUBJECT_INFO VARCHAR2(256),
    TARGET VARCHAR2(1024)
);

CREATE OR REPLACE TYPE EDN_BUSINESS_EVENT AS OBJECT (
    NAMESPACE VARCHAR2(256),
    LOCAL_NAME VARCHAR2(80),
    PAYLOAD SYS.XMLTYPE,
    COMPRESSED_EVENT DECIMAL(10),
    DECOMP_METHOD VARCHAR2(64)
);

Here is how the Deparment payload looks like:




Here is how first Employee record's payload looks like:




Here is the payload of the second Employee record:




You can see that both the child record's payload contains the new value for the parent entity, as specified in the child entity event definition earlier.

That's all.

JDev Release 11.1.1.4

6 comments:

  1. Thanks Lalit for writing this.
    It may sound noobish but I cant see AQ$EDN_EVENT_QUEUE_TABLE.
    What i have is AQ$_QUEUE_TABLES .Inside that I have 23 tables,one of them is EDN_EVENT_QUEUE_TABLE owned by the schema DEV_SOAINFRA but I don't remember whether I have given any password for this schema because I didn't explicitly created this schema ,so can you just guide me through how to access these tables.

    ReplyDelete
  2. AQ$EDN_EVENT_QUEUE_TABLE is a view so don't get confused by the suffix 'TABLE'. I guess you need to run RCU again as these schemas and tables are created by it automatically, and RCU asks for password for all the schemas it creates. There is an option to give same or different password for each schema in the RCU wizard.

    ReplyDelete
  3. hi,
    is there any way by which I can combine the lines details into one payload corresponding to its master

    ReplyDelete
  4. Hi is there any way to combine line with master records pls help

    ReplyDelete
  5. Hi is there any way to combine line with master records pls help

    ReplyDelete