0% found this document useful (0 votes)
66 views

Adapters DB 307 ExpertPolling

This document provides an overview and instructions for a sample that demonstrates expert polling strategies for an Oracle DB Adapter in Oracle SOA Suite 11g beyond what is exposed in the standard user interface. It describes four strategies - Shadow Table, Sysdate Logical Delete, Oracle SCN, and No After Read - and provides steps to build and run a sample for each strategy by customizing the TopLink metadata mappings and database queries.

Uploaded by

RK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Adapters DB 307 ExpertPolling

This document provides an overview and instructions for a sample that demonstrates expert polling strategies for an Oracle DB Adapter in Oracle SOA Suite 11g beyond what is exposed in the standard user interface. It describes four strategies - Shadow Table, Sysdate Logical Delete, Oracle SCN, and No After Read - and provides steps to build and run a sample for each strategy by customizing the TopLink metadata mappings and database queries.

Uploaded by

RK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Oracle SOA Suite 11g - Sample

SAMPLE NAME : adapters-db-307-ExpertPolling


COMPONENT : DB Adapter

SAMPLE NAME : adapters-db-307-ExpertPolling ........................................................ 1


COMPONENT : DB Adapter ...................................................................................... 1
OVERVIEW ....................................................................................................................... 1
PROVIDED FILES............................................................................................................. 2
STEP BY STEP INSTRUCTIONS .................................................................................... 2
RUNNING THE PREBUILT SAMPLE ........................................................................ 2
INSTALLING & CONFIGURING ............................................................................ 2
RUNNING THE SAMPLE......................................................................................... 2
VERIFYING EXECUTION ....................................................................................... 2
BUILDING THE SAMPLE............................................................................................ 3
SHADOW TABLE ..................................................................................................... 3
SYSDATE LOGICAL DELETE................................................................................ 5
ORACLE SCN............................................................................................................ 6
NO AFTER READ ..................................................................................................... 7

OVERVIEW

This bonus sample is subsequent to 207-AdvancedPolling, and shows some


ways to customize polling for events beyond what is exposed in the UI.

It shows a total of four expert strategies, Shadow Table, Sysdate Logical Delete,
Oracle SCN, and No After Read. These samples generally involve hand editing
the files generated by the DBAdapter UI, especially the TopLink metadata or-
mappings.xml file. TopLink is the technology on which the DbAdapter is built. A
fifth expert polling sample has its own sample: 308-RowidPolling.

Shadow table polling is like Control table except that rows are inserted into
MoviesCtrl after they have been processed, rather than before. Hence the keys
stored in the control table indicate which rows have already been processed, not
which ones are pending to be processed. In 10.1.3 this sample was named
‘PollingPureSQLOtherTableInsert’.

Sysdate Logical Delete is just a version of Logical Delete where the read value is
not static, but a function, i.e. sysdate. Hence unprocessed records have a
timestamp which is null, and processed ones are marked with the time at which
they were picked up.
Oracle SOA Suite 11g - Sample

Oracle SCN strategy is a final extension of Child Updates where the


last_updated column is actually the pseudo-column ora_rowscn. In this way you
can obtain completely transparent polling: The source tables are never modified
by the DbAdapter, but also they never need to be modified by the user either (i.e.
updating a last_updated column).

Finally NoAfterReadStrategy is one where the same records can be processed


again and again (often with a long polling interval). It is up to the SOA process to
update rows themselves such that they no longer are picked up by the polling
query.

PROVIDED FILES

This sample contains the SOA Project that you can deploy along with the sql
scripts.

STEP BY STEP INSTRUCTIONS

RUNNING THE PREBUILT SAMPLE

INSTALLING & CONFIGURING

• Execute the SQL in sql/setup.sql which is shared by all DbAdapter


samples.
• For OracleSCN execute the special sql/setup.sql which is contained in this
project.
• Open the jpr file in Jdeveloper, and deploy the sample to a running
WebLogic Server.

RUNNING THE SAMPLE

• Simply execute sqlplus @ start-shadowtable, @ start-


sysdatelogicaldelete, @ start-oraclescn, or @start-noafterread to kick off
either of the four strategies. As No After Read will poll the same records
continuously, you may also want to wait a bit and then execute @ stop-
noafterread.sql.

VERIFYING EXECUTION

• With adapter logging set to trace, you should see the polling SQL being
issued to the log files.
Oracle SOA Suite 11g - Sample

• After running the start script, go SELECT POLLING_STRATEGY FROM


MOVIES. It should correspond to the polling strategy that you started.

BUILDING THE SAMPLE

Please see the Database Adapter documentation, specifically the Database


Adapter Wizard Walkthrough. Please also see the MasterDetail tutorial, as many
screen shots from there are not duplicated here.

• Create a new SOAProject, with an empty composite in Jdeveloper. Don’t


forget to name it.

SHADOW TABLE

• Create a polling DbAdapter process (“Poll for New or Changed Records in


a table”).
• Import the tables MOVIES_IN and MOVIE_REVIEWS (but not
MOVIESCTRL).
• Choose the “Delete the Row(s) that were Read” strategy.
• Copy the sql which is generated for you into your clipboard and hit finish.
• Now open up the ShadowTable-or-mappings.xml outside of Jdeveloper
(the file is write protected). Look under the descriptor for MOVIES_IN
near the top, you should see an element that looks like:

<opm:querying xsi:type="toplink:query-policy">
<opm:queries>
<opm:query name="ShadowTableSelect" xsi:type="toplink:read-all-
query">
<toplink:reference-class>ShadowTable.MoviesIn</toplink:reference-
class>
<toplink:lock-mode>none</toplink:lock-mode>
<toplink:container xsi:type="toplink:list-container-policy">
<toplink:collection-type>java.util.Vector</toplink:collection-type>
</toplink:container>
</opm:query>
</opm:queries>
</opm:querying>

• We are going to add a custom sql where clause to this query. It will then
look like this:

<opm:querying xsi:type="toplink:query-policy">
<opm:queries>
<opm:query name="ShadowTableSelect" xsi:type="toplink:read-all-
query">
Oracle SOA Suite 11g - Sample

<toplink:call xsi:type="toplink:sql-call">
<toplink:sql>SELECT TITLE, DIRECTOR, STARRING, SYNOPSIS,
GENRE, RUN_TIME, RELEASE_DATE, RATED, RATING, VIEWER_RATING,
STATUS, TOTAL_GROSS, DELETED, SEQUENCENO, LAST_UPDATED,
POLLING_STRATEGY FROM MOVIES_IN WHERE POLLING_STRATEGY =
‘ShadowTable’ AND NOT (TITLE IN (SELECT MOVIE FROM
MOVIESCTRL))</toplink:sql>
</toplink:call>
<toplink:reference-class>ShadowTable.MoviesIn</toplink:reference-
class>
<toplink:lock-mode>none</toplink:lock-mode>
<toplink:container xsi:type="toplink:list-container-policy">
<toplink:collection-type>java.util.Vector</toplink:collection-type>
</toplink:container>
</opm:query>
</opm:queries>
</opm:querying>

• When adding the <toplink:call> element, it is after <toplink:timeout> (if it


exists), otherwise first under <opm:query>. To be safe try to remove any
returns from the select, and also the names, ordering, and number of
columns (between SELECT and FROM) must exactly match what was
generated in the wizard.
• Immediately after <opm:queries> and before <opm:querying>, add this
element:

<toplink:delete-query xsi:type="toplink:delete-object-query">
<toplink:call xsi:type="toplink:sql-call">
<toplink:sql>INSERT INTO MOVIESCTRL (MOVIE)
VALUES (#TITLE)</toplink:sql>
</toplink:call>
</toplink:delete-query>

• Note that #TITLE is a syntax used internally by TopLink. For a ‘delete’


query it will pass in the primary keys as parameters and expect this exact
wording (the names of the database columns, upper case). Here we are
taking the primary key but instead of doing a delete we are making it do an
insert (and to a different table)!
• After hitting finish, open up ShadowTable_db.jca, and add
DeleteDetailRows=”false” as a property. This makes sure that the detail
Movie_Reviews_in rows are not accidentally deleted:
Oracle SOA Suite 11g - Sample

• Create a Mediator and a transform.

SYSDATE LOGICAL DELETE

• Create a Delete polling service. You must always use Delete Polling
Strategy as this is the only strategy where the queries are sent unmodified
to TopLink.
• On the where clause page, add the extra condition WHERE
LAST_UPDATED IS NULL.

• Hit finish. As before edit or-mappings.xml outside of Jdeveloper and add


between </opm:queries> and </opm:querying> :

<toplink:delete-query xsi:type="toplink:delete-object-query">
<toplink:call xsi:type="toplink:sql-call">
<toplink:sql>UPDATE MOVIES_IN SET LAST_UPDATED = sysdate
WHERE TITLE = #TITLE</toplink:sql>
Oracle SOA Suite 11g - Sample

</toplink:call>
</toplink:delete-query>

• Edit SysdateLogicalDelete_db.jca and add <deleteDetailRows=”false”/>


• Create a Mediator and a transform

ORACLE SCN

• Create a Sequencing polling service.


• On the Sequencing page, instead of picking an existing column from the
drop-down, simply type ‘ora_rowscn’:

• On the next page choose ‘Poll for Child Updates’:


Oracle SOA Suite 11g - Sample

• Please edit OracleSCN_db.jca, and change

<property name="SequencingTableKey" value="MOVIES_IN"/>

to

<property name="SequencingTableKey" value="MOVIES_IN_SCN"/>

This is because the value must be a legal system change number. If the
same entry as the LastReadId sample is used, it will often be 0 or 20, which may
be illegal values. Also the initial value should be null, such that on the first
iteration all rows will be processed, but then the latest SCN will be stored.

• Hit finish and model the mediator and transform.

NO AFTER READ

• Create a Delete Polling service and hit finish.


• Edit NoAfterRead_db.jca and change

<property name="PollingStrategy" value="DeletePollingStrategy"/>

to:
Oracle SOA Suite 11g - Sample

<property name="PollingStrategy" value="NoAfterReadPollingStrategy"/>

• Make sure to add a where clause to the polling query, like


POLLING_STRATEGY = ‘NoAfterRead’, so that it can be quickly disabled.

You might also like