Oracle英文版培训课件之Implement Streams:les18_第1页
Oracle英文版培训课件之Implement Streams:les18_第2页
Oracle英文版培训课件之Implement Streams:les18_第3页
Oracle英文版培训课件之Implement Streams:les18_第4页
Oracle英文版培训课件之Implement Streams:les18_第5页
已阅读5页,还剩25页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Message QueuingConceptsObjectivesAftercompletingthislesson,youshouldbeabletodothefollowing:ConfiguresecurequeueusersforenqueuinganddequeuingmessagesConfigureamessagingclientfordequeuingeventsDescribetheprocessofenqueuinganddequeuingeventsConfiguremessagenotificationManageAdvancedQueuingqueues,queuetables,propagationschedules,andtransformationsbyusingEnterpriseManagerEnqueuingEventsEventscanbeenqueuedintoastagingqueueinthreeways:AcaptureprocessenqueuesDMLandDDLchangesasLCRevents.AuserapplicationenqueuesusermessagesorLCRsaseventsoftypeSYS.AnyData.

Anenqueuedirectiveinstructsanapplyprocesstoenqueuecertaineventsintothestagingqueue.SecureQueueUsersForausertobeabletoenqueueordequeuemessagesfromasecureagentqueue,youmustconfiguretheuserasasecurequeueuser.UseDBMS_STREAMS_ADM.SET_UP_QUEUEtoconfigureasecurequeueuser.BEGINDBMS_STREAMS_ADM.SET_UP_QUEUE(queue_table=>'ix.streams_queue_table',queue_name=>'streams_queue',queue_user=>'ix');END;/SubscriptionsandRecipientListsTheSYS.AnyDataqueueisamulticonsumerqueuethatallowsconsumptionofamessagebymorethanoneconsumer.Alistofconsumersforamessageisidentifiedbyusing:SubscriptionAddasubscriptiontoaqueuebyusingtheDBMS_AQADM.ADD_SUBSCRIBERprocedureRecipientlistSpecifiedintherecipient_listmessagepropertywhenthemessageisenqueuedProceduresforConfiguringAQAgentsDBMS_AQADM.CREATE_AQ_AGENT(agent_nameINVARCHAR2,enable_httpINBOOLEANDEFAULTFALSE,enable_smtpINBOOLEANDEFAULTFALSE,enable_anypINBOOLEANDEFAULTFALSE);DBMS_AQADM.ENABLE_DB_ACCESS(agent_nameINVARCHAR2,db_usernameINVARCHAR2)DBMS_AQADM.ADD_SUBSCRIBER(queue_nameINVARCHAR2,subscriberINsys.aq$_agent,ruleINVARCHAR2DEFAULTNULL,transformationINVARCHAR2DEFAULTNULL);CreatingaSubscriberToconfigureasecurequeueuserasasubscriber,thusenablingthemtodequeuemessagesoreventsfromaqueue,usethe:SYS.AQ$_AGENTtypetospecifytheAQagentDBMS_AQADM.ADD_SUBSCRIBERproceduretospecifythattheagentisasubscribertothequeueDECLAREsubscriberSYS.AQ$_AGENT;BEGINsubscriber:=SYS.AQ$_AGENT('IX',NULL,NULL);SYS.DBMS_AQADM.ADD_SUBSCRIBER(queue_name=>'ix.streams_queue',subscriber=>subscriber);END;/MessagingClientUserAmessagingclient:Consumesuser-enqueuedeventsfromaSYS.AnyDataqueuebasedonrulesIsinvokedbyauserorapplicationIsassociatedwithonlyonedatabaseuserAmessagingclientuser:CreatesthemessagingclientusingproceduresintheDBMS_STREAMS_ADMpackageIsgrantedtheprivilegestodequeuefromthequeueCanbeassociatedwithmanymessagingclientsCreatingaMessagingClientDBMS_STREAMS_ADM.ADD_TABLE_RULES(table_name=>'oe.orders',streams_type=>'dequeue',streams_name=>'ORDERS_DEQ',queue_name=>'ix.streams_queue',source_database=>'',inclusion_rule=>true);Applicationdequeue

usingmessagingclientCreatingMessagingClientRulesDBMS_STREAMS_ADM.ADD_MESSAGE_RULE(message_type=>'ix.order_event_typ',rule_condition=>':msg.delivery_date<SYSDATE',streams_type=>'dequeue',streams_name=>'ORDERS_DEQ',queue_name=>'ix.streams_queue',inclusion_rule=>true);Applicationdequeue

usingmessagingclientUser-CreatedEventsMustbeexplicitlyenqueuedCanbeamessageofanydatatypeoruser-definedtypeMustbewrappedinaSYS.AnyDatatypetobeenqueuedinaSYS.AnyDataqueueCanalsobeaJavaMessageService(JMS)typemessageUser-EnqueuedEventsThemessagepayloadisoftypeSYS.AnyData.YoucanenqueuemessageswithdifferenttypesofpayloadsintoaStreamsstagingqueuebywrappingthemessageintheSYS.AnyDatatype:User-createdLCRsStandarddatatypesUser-definedobjecttypesSYS.AnyData

typeApplicationWrappingMessagePayloadsUsetheCONVERT<data_type>staticfunctionsoftheSYS.AnyDatatype,wheredata_typeisthetypeofobjecttowrap.Alldatatypesaresupportedexcept:CLOB,NCLOB,BLOB,orROWIDUser-definedtypeswithLOBattributes(includingCLOB,

NCLOB,andBLOB)NestedtableSYS.AnyData.ConvertObject(ix.order_event_typ(2424,3350,146,'Elia','Fawcett',4,TO_DATE('18-AUG-02')))StreamsMessageswithObjectTypesEachuser-definedtypethatisusedinamessagemustexistateverydatabasewherethemessagemaybestagedinaqueue.Thetypemusthavethesamename,owner,andformateachdatabase.Typeevolutionandinheritanceisnotsupported.Thetype’sobjectidentifier(OID)doesnothavetobethesameforeachdatabase.StreamsMessagesContainingLCRsAnexplicitlyenqueuedmessagecanbe:AnLCRwrappedintheSYS.AnyDatatypeAuser-definedtypethatcontainsanLCRasanattributeLCRwrappedin

SYS.AnyDatatypeidLCRObjecttypewithLCR

attributewrappedin

SYS.AnyDatatypeDequeuingMessagesinStreamsTheoperationofretrievingmessagesfromaqueueisknownasdequeuing.User-enqueuedeventsinthestagingqueuecanbedequeuedautomatically:Applyhandlesuser-enqueuedLCReventsinthesamemannerascapturedLCRevents.Applyconfiguredwithamessagehandlerdequeuesandprocessesnon-LCRevents.YoucanusetheDBMS_STREAMS_ADM.DEQUEUEorDBMS_AQ.DEQUEUEprocedurestoexplicitlydequeueuser-enqueuedevents.UnwrappingMessagePayloadsUsetheGET<datatype>staticfunctionsoftheSYS.AnyDatatype,where<datatype>isthetypeofobjecttounwrap.UsetheGETTYPEorGETTYPENAMEstaticfunctionsoftheSYS.AnyDatatypetodeterminethetypeofembeddeddata....IF(evt.GetType()=DBMS_TYPE.TYPECODE_VARCHAR2)

THENnum_var:=evt.GetVarchar2(string_var);ELSEIF(evt.GetTypeName()='SYS.LCR$_ROW_RECORD')THENnum_var:=evt.GetObject(rowLCR);...MessageHandlersforUserMessagesUsermessages(non-LCRevents)arealwaysprocessedbyamessagehandler.Themessagehandlermustperformanyneededdependencychecking.Therecanbeonlyasinglemessagehandlerperapplyprocess.Non-LCReventMessagehandlerMessageHandlersAmessagehandlerisauser-definedprocedurethatcanprocessnon-LCRusermessagesinacustomizedwayforyourenvironment.Youcanspecifyamessagehandlerforanapplyprocessbyusingthemessage_handlerparameterintheDBMS_APPLY_ADMpackage:CREATE_APPLYALTER_APPLYTheapplyprocesshandlesthedequeueoperation.Ifdependenciesexistbetweenthesemessagesinyourenvironment,setparallelismto1fortheapplyprocess.MessageHandler:ExampleCREATEORREPLACEPROCEDUREorder_events_mh

(evtSYS.AnyData)ISordorder_event_typ;dummyNUMBER;BEGINIF(evt.getTypeName='OE.ORDER_EVENT_TYP')THENdummy:=evt.getObject(ord);CASEWHENord.shipdays=0THEN<routebilling>;WHENord.shipdays<=3THEN<routepriority>;WHENord.shipdays>3THEN<routenormal>;ENDCASE;INSERTINTOoe.order_logVALUES(ord.order_number,ord.part_number,SYSTIMESTAMP);ENDIF;END;UsingaMessageHandlerCreateanapplyprocessthatisassociatedwiththedestinationqueue.Configurethemessagehandlerfortheapplyprocess.Createatleastonerulefortheapplyprocessrelatingtotheuser-enqueuedevent,andplaceitinthepositiveornegativeruleset.Starttheapplyprocess.ConfiguringMessageNotificationEXECUTE-DBMS_STREAMS_ADM.SET_MESSAGE_NOTIFICATION(-streams_name=>'ORDERS_DEQ',-notification_action=>'john.doe@',-notification_type=>'MAIL',-include_notification=>true,-queue_name=>'IX.STREAMS_QUEUE');MessagingclientNotificationSupportedNotificationTypesForURLnotifications,specifyaURLwithouttheprefixhttp://ForPL/SQLprocedurenotifications,specifyaPL/SQLprocedurename:Fore-mailnotifications,specifyane-mailaddress:notification_type=>'HTTP'notification_action=>':8080'notification_type=>'PROCEDURE'notification_action=>'oe.notify_addr_arrival'

notification_type=>'MAIL'notification_action=>'John.Doe@'

PurgingtheQueueTheDBMS_AQADM.PURGE_QUEUE_TABLEprocedure:RemovesmessagesfrompersistentqueuesIsusefulforbothsingle-consumerandmulticonsumerqueuesCanbecustomizedtopurgeonlymessagesthatmeetspecificconditionsPurgingtheQueueWhenpurgingeventsfromaqueue,youcanspecify:ApurgeconditionWhetheranexclusivelockisobtainedduringthepurgeoperationDECLAREpurge_optDBMS_AQADM.aq$_purge_options_t;BEGINpurge_opt.block:=TRUE;DBMS_AQADM.PURGE_QUEUE_TABLE(queue_table=>'STRMADMIN.STREAMS_QUEUE_TABLE',purge_condition=>'queue=''STREAMS_QUEUE''',purge_options=>purge_opt);END;PurgeConditions:ExamplesPurgealleventsinaqueuetable

Purgeallevent

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论