Oracle SOA - Java Blog - Polling With The DbAdapter in A Clustered Environment
Oracle SOA - Java Blog - Polling With The DbAdapter in A Clustered Environment
OracleSOA/Javablog
Articlescontainingtips,tricksandnicetoknowsrelatedtoOracleSOAandJavadevelopment
vrijdag6april2012 Searchinthisblog
PollingwiththeDbAdapterinaclusteredenvironment Go!
Introduction
+8 Dit aanbevelen op Google
Mostcustomersuseaclusteredproductionenvironment.Thedevelopmentenvironmentisoftennot
clustered.Thereareseveralthingstoconsiderfordeveloperswhenthesoftwaredevelopedwill
eventuallyruninaclusteredenvironment.Itwouldbeashameifthesoftwarehasbeendeveloped,
unittested,systemtested,acceptedbytheusersandthenbreaksontheproductionsystem. Aboutme
MaartenSmeets
IwillfirstdiscusstheDbAdapterandpollinginthispost.Thisisnotacompletedescriptionofallthe
Volgen 70
settingswhichcaninfluencethisbehavior,justsomethingsI'vetriedandproblemsI'veencountered.
Mijnvolledigeprofiel
I'veusedthe(activeactivecluster)setupasdescribedin weergeven
http://javaoraclesoa.blogspot.com/2012/03/oraclesoasuiteclusterpart1.html
http://javaoraclesoa.blogspot.com/2012/03/oraclesoasuiteclusterpart2.html
ThisarticleisabouttheDbAdapter.AnerrorwhichcanoccurwhenusingtheAqAdapterwhen OracleACEAssociate
dequeueinginaclusteredenvironmentisthatamessageisqueuedonceanddequeuedmorethen
once.Thiscanoccurin11.2databases.Lookat
http://www.oracle.com/technetwork/middleware/docs/aiasoarelnotesps51455925.htmlfora
descriptiononhowtofixthis.Belowhasbeencopiedfromthementioneddocument
Bug:13729601
Added:20February2012
Platform:All
Thedequeuerreturnsthesamemessageinmultiplethreadsinhighconcurrencyenvironmentswhen
Disclaimer
Oracledatabase11.2isused.Thismeansthatsomemessagesaredequeuedmorethanonce.For
example,inOracleSOASuite,ifService1suddenlyraisesalargenumberofbusinesseventsthat
Theviewsexpressedonthisblogaremy
aresubscribedtobyService2,duplicateinstancesofService2triggeredbythesameeventmaybe
seeninanintermittentfashion.Thesamebehaviorisnotobservedwitha10.2.0.5databaseorinan ownanddonotnecessarilyreflectthe
11.2databasewithevent10852level16384settodisablethe11.2dequeueoptimizations. viewsofmyemployerorcustomer.
Workaround:Performthefollowingsteps:
Allsamplecodeisprovidedfor
Logintothe11.2database: illustrativepurposesonly.These
CONNECT/ASSYSDBA exampleshavenotbeenthoroughly
testedunderallconditions.Thewriter
SpecifythefollowingSQLcommandinSQL*Plustodisablethe11.2dequeueoptimizations:
therefore,cannotguaranteeorimply
SQL>altersystemsetevent='10852tracenamecontextforever,
level16384'scope=spfile reliability,serviceability,orfunctionof
theseprograms.
Pollingsetup
Allprogramscontainedhereinare
Inanactive/activeclusterconfiguration,adeployedprocesswillhavetwoinstancesofaprocess providedtoyou"ASIS"withoutany
pollingonthesametable.Inthiscaseitisimportanttoconsiderifitwillbeaproblemifmorethen
warrantiesofanykind.Theimplied
oneinstancepicksupthesameentryinthetable.
warrantiesofnoninfringement,
Iusedthefollowingdatabasesetuptosimulateandlogthetest merchantabilityandfitnessfora
http://dl.dropbox.com/u/6693935/blog/cluster_test.sql particularpurposeareexpressly
disclaimed.
Thescriptcontainsthreetables
POLLING_TEST_CLUSTER
thistablewillbeusedbytheDbAdapterforpolling
POLLING_TEST_LOG FollowbyEmail
thistablewilllogstatuschangesinPOLLING_TEST_CLUSTER(POLLING_TEST_CLUSTERhas
abeforeupdatetrigger) Emailaddress... Submit
POLLING_TEST_OUTPUT
aBPELprocesswillreadfromPOLLING_TEST_CLUSTERandputentriesinthistable.thistable
http://javaoraclesoa.blogspot.in/2012/04/pollingwithdbadapterinclustered.html 1/7
10/6/2016 OracleSOA/Javablog:PollingwiththeDbAdapterinaclusteredenvironment
hasauniqueconstraintontheIDcolumn.thesameIDisusedasinPOLLING_TEST_CLUSTER
thusifthesameentryfromthePOLLING_TEST_CLUSTERtableispickeduptwicebyBPEL,itwill
causeauniquekeyconstraintwhenittriestoinserttheentryinPOLLING_TEST_CLUSTER
I'veuseda'pragmaautonomous_transaction'intheloggingprocedure.Thiswillfail(withanORA
06519:activeautonomoustransactiondetectedandrolledback)ifIdon'tendtheprocedurewithan
explicitcommit.
NextconfigureadatasourceandthedatabaseadapterintheWeblogicConsolesoyoucanusethem
inBPEL.Don'tcreateanXAdatasource!Itwillcauseproblemswithautonomoustransactionssuch
asjava.sql.SQLException:Cannotcallrollbackwhenusingdistributedtransactions(XAdatasources
canalsocauseproblemswithdatabaselinkshttp://javaoraclesoa.blogspot.com/2012/02/exception
occuredwhenbindingwas.html)
WhenconfiguringtheDbAdapter,keepinmindthatyouhavetocopythePlan.xmlfile(deployment Subscribeto
planfortheDbAdapter)totheothermanagedserverifyouhavenotconfiguredasharedstoragefor
thisfile(whichissuggestedintheEnterpriseDeployment
Guide,http://docs.oracle.com/cd/E17904_01/core.1111/e12036/extend_soa.htm,paragraph5.21.1).If
Berichten
youdon'tdothis,theconnectionfactorywillnotbeavailableintheothermanagedserver. Reacties
Pollingtest
Followers
Youcandownloadtheprocesseshere
http://dl.dropbox.com/u/6693935/blog/FilePollingTest.zip Followers(9)Next
IcreatedasmallprocesstoinsertarecordinthePOLLING_TEST_CLUSTERtablewithastatus
NEWsoitwoulddirectlybepickedup.IusedSOAPUI(http://www.soapui.org/)todoastresstest
andcallthisprocessalargenumberoftimes.
Iwasabletoproducetheerror(asmallnumberoftimesathighloads)thattwoinstancesofthe Follow
adapter,runningondifferentserversinthecluster,pickedupandprocessedamessageatthesame
time.Ihavealsoseenthishappeningatacustomer.
Inmysetupthissituationwouldcauseauniqueconstraintviolationasshownbelow Populaireberichten
LoopsinBPEL1.1and
<bpelFault><faultType>0</faultType><bindingFaultxmlns="http://schemas.oracle.com/bpel/extension"><part
2.0
name="summary"><summary>Exceptionoccuredwhenbindingwasinvoked.Exceptionoccuredduringinvocationof
IntroductionWhen
JCAbinding:"JCABindingexecuteofReferenceoperation'insert'faileddueto:DBWriteInteractionSpecExecuteFailed
programminginBPEL,an
Exception.insertfailed.Descriptorname:[write_textline_DB.PollingTestOutput].Causedby oftenusedconstructionis
java.sql.BatchUpdateException:ORA00001:uniqueconstraint(TESTUSER.POLLING_TEST_OUTPUT_PK) thefollowingtheinputofaprocess
violated.PleaseseethelogsforthefullDBAdapterloggingoutputpriortothisexception.Thisexceptionisconsidered containsacollectionofele...
notretriable,likelyduetoamodellingmistake.ToclassifyitasretriableinsteadaddpropertynonRetriableErrorCodes
withvalue"1"toyourdeploymentdescriptor(i.e.weblogicra.xml).Toautoretryaretriablefaultsetthese Pollingwiththe
composite.xmlpropertiesforthisinvoke:jca.retry.interval,jca.retry.count,andjca.retry.backoff.Allpropertiesare
DbAdapterinaclustered
environment
integers.".TheinvokedJCAadapterraisedaresourceexception.Pleaseexaminetheaboveerrormessagecarefullyto
determinearesolution.</summary></part><partname="detail"><detail>ORA00001:uniqueconstraint
IntroductionMost
customersusea
(TESTUSER.POLLING_TEST_OUTPUT_PK)violated</detail></part><partname="code"><code>1</code></part>
clusteredproductionenvironment.The
</bindingFault></bpelFault> developmentenvironmentisoftennot
clustered.Thereareseveral...
ThisoccurredevenwiththeNumberOfThreadsvaluesetto1(thisisthedefault)
DbAdapter,connection
factories,connection
poolsanddatasources
Goingfroma
BPMN,BPELorMediator
processinstancetothedatabaseis
notashortroad.Onthisroad,several
abstractionlayersneedtobe...
Blogarchief
2016(14)
2015(25)
BelowIwilldescribetwopossiblesolutionsforthisissueandmyexperiencewithit.Distributed 2014(23)
pollingandusingaReservedValue. 2013(25)
2012(33)
DistributedPolling
december(2)
Thisisalsodescribedmoreextensively november(2)
http://javaoraclesoa.blogspot.in/2012/04/pollingwithdbadapterinclustered.html 2/7
10/6/2016 OracleSOA/Javablog:PollingwiththeDbAdapterinaclusteredenvironment
inhttp://www.oracle.com/technetwork/database/features/availability/maasoaassesment194432.pdf
oktober(2)
ItispossibletosettheDbAdapterpropertytododistributedpolling september(4)
augustus(3)
juli(2)
juni(3)
mei(2)
april(3)
Thingstomindina
clusteredSOASuite
11genviro...
SchedulingEDNBusiness
Eventsusing
DBMS_SCHEDULE...
Pollingwiththe
DbAdapterina
clusteredenvironm...
DistributedPollingmeansthatwhenarecordisread,itislockedbythereadinginstance.Another maart(5)
instancewhichwantstopickuptherecordskipslockedrecords.Thiscanhowevercauseproblems februari(5)
withlockswhichcouldoriginatefromdifferentsourcesthentheprocessesrecordswhichwould
requireprocessing,couldbeskipped.
Also,aBPELprocessisbydefaultinvokedasynchronouslybytheDbAdapter Labels
ThiscausesthelocktobereleasedrightaftertheDbAdapterisdonewithitandtheBPELprocessis
started.ThismakesacaseforusingthelogicaldeleteprovidedintheDbAdapterifyouwanttouse
thismechanismandnotupdatethefieldlaterintheBPELprocess.
UsingdistributedpollingincombinationwithlogicaldeleteishowevernotrecommendedbyOracle
fromthemanual(HelpbuttonintheJDeveloperwizard)Abetteralternativeistoseteither
NumberOfThreadsorMarkReservedValueforlogicaldeleteordeletestrategies.
Itestedthesameprocesswithdistributedpollingenabed.Stillasmallnumberofprocessesfailed
withauniquekeyconstraintthusthismechanismisnot100%safe.Ididgetabitbetterresults
however.
Unreadandreservedvalue
UnreadValue
SettingtheUnreadvaluecausestheselectqueryusedforpollingtocontainawhereclause
matchingthefieldtotheUnreadvalue.DuringmytestIfoundthatsettingtheUnreadvalueinthe
DbAdapterconfigurationwizardcausedmyprocessnottopickuprecordswiththesetvalue.Ihave
howeverseenatcustomersthatthisvaluewasusedsuccesfullytolimittherecordsbeingpickedup.
Thehelpdocumentationsaysthefollowing(whichmademedoubtthepurposeofthisfield)Unread
Value
(Optional)Enteranexplicitvaluetoindicatethattherowdoesnotneedtoberead.Duringpolling,
http://javaoraclesoa.blogspot.in/2012/04/pollingwithdbadapterinclustered.html 3/7
10/6/2016 OracleSOA/Javablog:PollingwiththeDbAdapterinaclusteredenvironment
thisrowisskipped.
Thebelowimageshowedasettingthatdidwork.
Reservedvalue
InthereleasenotesofSOASuite11.1.1.4
(https://supporthtml.oracle.com/epmos/faces/ui/km/SearchDocDisplay.jspx?
_afrLoop=3308018508015000&type=DOCUMENT&id=1290512.1&displayIndex=3&_afrWindowMode=
0&_adf.ctrlstate=y8cqyff7j_134),thefollowingisdocumented
18.1.5.1DistributedPollingUsingMarkReservedValueDisabledbyDefault
Inthisrelease,Oraclerecommendsthatyouusethenewdistributedpollingapproachbasedonskip
locking.WheneditinganOracleDatabaseAdapterservicewhichhasaMarkReservedValueset,that
valuewillberemovedtoenablethenewbestpractice.Tousetheolddistributedpollingapproach
basedonareservedvalue,selectthevaluefromthedropdownmenu.
InthehelpinJDeveloper,thefollowingisdocumentedfordistributedpolling(skiplockingas
mentionedabove)DistributedPolling.Selectthischeckboxifdistributedpollingisrequired.
However,thisimplementationusesaSELECTFORUPDATEcommand.Abetteralternativeistoset
eitherNumberOfThreadsorMarkReservedValueforlogicaldeleteordeletestrategies.
Asyoucanseeintheabovescreenshots,itispossibletosetareservedvalue.
http://javaoraclesoa.blogspot.in/2012/04/pollingwithdbadapterinclustered.html 4/7
10/6/2016 OracleSOA/Javablog:PollingwiththeDbAdapterinaclusteredenvironment
Thisreservedvalue(MarkReservedValuein*_db.jca)causesaninstanceoftheprocesstosetan
identifier.Thisidentifierisskippedbytheotherpollinginstancesinthecluster.
WhenIhowevertriedtousethissetting(ReservedValue)in11.1.1.6(ofcoursesettingtheUnread
valueto''),InoticedtheDbAdapterdidnotpickupanymessages.WhenchangingtheReadValue
andredeploying(afteremptyingthereservedvalue),itdidpickupmessagesagainimmediately.I'm
notsurewhyitdidn'tworkinthistest.Myguessisforthistowork,anadditionalsettingisrequired.
IfI'vefoundthissetting,Iwillupdatethispost.AlsonoticethewizardemptiestheReservedValueif
yougothroughitagain.Forthetimebeing,I'llusetheskiplockingsetting(distributedpolling).
SingletonDbAdapter
Basedonasuggestiondoneinthecommentsofthispost,thereisalsotheoptiontoconfigurethe
DbAdapterasasingletonwithaJCAproperty.
Seethedocumentationformoreinformationonthis
http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/life_cycle.htm#BABDAFBH
Thebehaviorofthispropertyisdescribedinthefollowingpost
http://ayshaabbas.blogspot.nl/2012/11/dbadaptersingletonbehaviourinhigh.html
GeplaatstdoorMaartenSmeetsop18:54
Labels:bpel,cluster,dbadapter,distributedpolling,markreservedvalue,polling,reservedvalue,
singleton
8 reacties
Reageren
Beste opmerkingen
1 Beantwoorden
+1 1 Beantwoorden
2
+4 1 Beantwoorden
5
Abonnerenop:Reactiesplaatsen(Atom)
http://javaoraclesoa.blogspot.in/2012/04/pollingwithdbadapterinclustered.html 6/7
10/6/2016 OracleSOA/Javablog:PollingwiththeDbAdapterinaclusteredenvironment
SjabloonAwesomeInc..MogelijkgemaaktdoorBlogger.
http://javaoraclesoa.blogspot.in/2012/04/pollingwithdbadapterinclustered.html 7/7