Home Database Mysql Tutorial TIBCO ESB实战系列:TIBCO数据库适配器双向数据同步解决方案

TIBCO ESB实战系列:TIBCO数据库适配器双向数据同步解决方案

Jun 07, 2016 pm 03:11 PM
Actual combat data database series adapter

作者:任成钢 来源:TechTarget中国 原文:http://www.searchsoa.com.cn/showcontent_48908.htm 【TechTarget中国原创】 首先声明,我不是某个厂商的托儿,只是就自己目前从事的咨询工作经验,希望能为大家提供一种参考。下面就给大家介绍一下一个基于TIBCO

作者:任成钢    来源:TechTarget中国
原文:http://www.searchsoa.com.cn/showcontent_48908.htm

 

【TechTarget中国原创】首先声明,我不是某个厂商的托儿,只是就自己目前从事的咨询工作经验,希望能为大家提供一种参考。下面就给大家介绍一下一个基于TIBCO数据库适配器的双向数据同步解决方案。

  工作原理

  TIBCO数据库适配器(TIBCO Adapter for Active Database),简称ADB,是一款非常优秀的关系型数据库数据发布与订阅适配器产品,结合TIBCO的其他应用集成产品(比如TIBCO BusinessWorks、TIBCO EMS等),能够通过简单的配置,就能够实现同构或者异构数据库之间的数据同步应用。TIBCO ADB的工作原理如下:

  ADB数据发布:

TIBCO ESB实战系列:TIBCO数据库适配器双向数据同步解决方案

  ADB在源数据表的数据库中,根据源表的格式建立发布表,并在源表上建立触发器,监测源表的数据变化(增删改),并将变化的数据插入到发布表中,ADB Agent会定时查询发布表(表中有一个发布状态标志,未发布的数据,即新数据状态为N),并将新插入发布表的数据发布出去(数据发布后,发布状态变为C)。发布的数据将由ADB Agent转换成消息发送给订阅方(TIBCO BW或者ADB订阅服务)。

  ADB数据订阅:

 TIBCO ESB实战系列:TIBCO数据库适配器双向数据同步解决方案

  ADB在目的数据表的数据库中,根据目的表的格式建立异常表,ADB Agent接收到发布方(TIBCO BW或者ADB发布服务)发送的消息,将其转换为数据,并根据数据中的操作标识(增删改),直接写入目的表中。当出现数据操作异常时,比如主键重复,数据类型错误等,造成目的表更新失败,会将错误的数据记录到异常表中。

  在配置ADB发布和订阅过程中,建立的表和触发器都由ADB自动完成,并提供脚本,用户可以根据需要进行修改。

  双向数据同步

  在进行数据同步类应用的实施过程中,经常会遇到双向同步的问题,比如两个数据库,任意一个数据库中的数据发生变化,都需要将数据同步给另一个库。这种情况下如果不进行限制,可能会出现数据同步循环问题,两边的数据不断的更新,不断的触发新的数据发布。幸运的是ADB提供了循环监测功能(Loop Detection),防止这种循环更新的发生。循环监测的原理如下:

  ADB在源表中增加了一个的特定字段(ADB_SOURCE),触发器会监测这个字段,如果该字段是由ADB的订阅服务更新的,则触发器不会将更新的数据插入发布表;如果该字段在数据更新时没有更新,则此数据是应用更新的,触发器会将数据插入到发布表,由发布服务进行发布。如下所示:

以下是引用片段:
CREATE OR REPLACE TRIGGER TRI_P_FILE AFTER INSERT OR DELETE OR UPDATE ON TAB_FILE
FOR EACH ROW
DECLARE
 updating_key_fields EXCEPTION;
BEGIN
 IF :NEW.ADB_SOURCE = 'T' THEN return;
 END IF;

 IF INSERTING THEN
 INSERT INTO P_STD_FILE_BACK VALUES (
  :NEW.FILE_ID,
  :NEW.FILE_NAME,
……
END TAB_FILE;
/

  利用这个新增的字段,限制触发器对发布表的更新,有效的限制了数据的循环更新问题。

  新的挑战

  但是在最近的一次实施中,遇到了新的问题。一家大型集团,有很多相对独立的子部门(公司),集团总部推广了一套系统,这套系统是各个单位(包括集团总部和子部门)独立部署的,并要求各个单位之间实现数据的实时/准实时同步,数据的更新可能发生在任何一个单位,其他的单位都需要接收到更新的数据并写入自己的数据库,形成双向同步。这种场景非常适合使用应用集成产品,我们向客户推荐了TIBCO BusinessWorks、TIBCO ADB,并使用TIBCO EMS作为消息服务器。但是在处理数据双向同步问题上,客户提出了更高的要求,这套系统已经开发并在部分单位运行了多年,按照TIBCO ADB默认的在源表增加字段的方式来处理双向同步情况,目前的系统可能会出现问题,他们也不想对现有的系统进行修改,所以要求不能修改源表的表结构。

  解决方案

  为了解决这个问题,我们提出了如下的解决方案:

  客户使用的数据库为Oracle数据库,基于Oracle的一些特性,我们不再使用增加字段的方式进行循环监测,改成采用区分用户的方式。即ADB操作Oracle数据表采用与业务系统不同的数据库用户,比如业务系统使用的数据库用户为business,ADB使用tibco。
然后对ADB生成的触发器脚本进行修改,加入如下(红色字体)的判断:

以下是引用片段:
CREATE OR REPLACE TRIGGER TRI_P_FILE AFTER INSERT OR DELETE OR UPDATE ON TAB_FILE
FOR EACH ROW
DECLARE
 updating_key_fields EXCEPTION;
BEGIN
 IF USER = 'TIBCO' THEN RETURN;
 END IF;
 IF INSERTING THEN
 INSERT INTO P_STD_FILE_BACK VALUES (
  :NEW.FILE_ID,
  :NEW.FILE_NAME,
……
END TAB_FILE;
/

  由此判断如果更新数据的用户是tibco,则当前数据时由ADB订阅服务进行更新的,不需要插入发布表进行发布(因为所有ADB订阅服务的数据来源都是其他的ADB发布服务);如果是非tibco用户,则数据是由业务系统进行更新的,需要插入发布表进行发布。

  通过上述方法,即可以不必修改数据结构实现双向数据同步的中的循环监测,避免循环更新。

  使用此种解决方案,要注意如下几个问题:

  首先要为ADB使用的数据库用户赋予CONNECT和RESOURCE角色,并赋予CREATE ANY TRIGGER权限

  其次要为ADB使用的用户赋予业务表的操作权限,比如:

以下是引用片段:
  grant select, insert, update, delete on  TAB_FILE  to TIBCO;

  该操作由业务系统用户执行

  然后为了更方便的再业务表上建立触发器,要为业务表建立同义词,比如:

以下是引用片段:
  create synonym TAB_FILE  for BUSINESS. TAB_FILE;

  该操作由ADB操作用户执行

  最后使用ADB操作用户执行由ADB生成的发布表、异常表和触发器的脚本。

  至此,双向数据同步解决方案就此完成,完美的解决了客户提出的问题。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
Xiaomi 15 series full codenames revealed: Dada, Haotian, Xuanyuan Xiaomi 15 series full codenames revealed: Dada, Haotian, Xuanyuan Aug 22, 2024 pm 06:47 PM

The Xiaomi Mi 15 series is expected to be officially released in October, and its full series codenames have been exposed in the foreign media MiCode code base. Among them, the flagship Xiaomi Mi 15 Ultra is codenamed "Xuanyuan" (meaning "Xuanyuan"). This name comes from the Yellow Emperor in Chinese mythology, which symbolizes nobility. Xiaomi 15 is codenamed "Dada", while Xiaomi 15Pro is named "Haotian" (meaning "Haotian"). The internal code name of Xiaomi Mi 15S Pro is "dijun", which alludes to Emperor Jun, the creator god of "The Classic of Mountains and Seas". Xiaomi 15Ultra series covers

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

AI startups collectively switched jobs to OpenAI, and the security team regrouped after Ilya left! AI startups collectively switched jobs to OpenAI, and the security team regrouped after Ilya left! Jun 08, 2024 pm 01:00 PM

Last week, amid the internal wave of resignations and external criticism, OpenAI was plagued by internal and external troubles: - The infringement of the widow sister sparked global heated discussions - Employees signing "overlord clauses" were exposed one after another - Netizens listed Ultraman's "seven deadly sins" Rumors refuting: According to leaked information and documents obtained by Vox, OpenAI’s senior leadership, including Altman, was well aware of these equity recovery provisions and signed off on them. In addition, there is a serious and urgent issue facing OpenAI - AI safety. The recent departures of five security-related employees, including two of its most prominent employees, and the dissolution of the "Super Alignment" team have once again put OpenAI's security issues in the spotlight. Fortune magazine reported that OpenA

The best time to buy Huawei Mate 60 series, new AI elimination + image upgrade, and enjoy autumn promotions The best time to buy Huawei Mate 60 series, new AI elimination + image upgrade, and enjoy autumn promotions Aug 29, 2024 pm 03:33 PM

Since the Huawei Mate60 series went on sale last year, I personally have been using the Mate60Pro as my main phone. In nearly a year, Huawei Mate60Pro has undergone multiple OTA upgrades, and the overall experience has been significantly improved, giving people a feeling of being constantly new. For example, recently, the Huawei Mate60 series has once again received a major upgrade in imaging capabilities. The first is the new AI elimination function, which can intelligently eliminate passers-by and debris and automatically fill in the blank areas; secondly, the color accuracy and telephoto clarity of the main camera have been significantly upgraded. Considering that it is the back-to-school season, Huawei Mate60 series has also launched an autumn promotion: you can enjoy a discount of up to 800 yuan when purchasing the phone, and the starting price is as low as 4,999 yuan. Commonly used and often new products with great value

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI 70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI Jun 13, 2024 pm 03:47 PM

70B model, 1000 tokens can be generated in seconds, which translates into nearly 4000 characters! The researchers fine-tuned Llama3 and introduced an acceleration algorithm. Compared with the native version, the speed is 13 times faster! Not only is it fast, its performance on code rewriting tasks even surpasses GPT-4o. This achievement comes from anysphere, the team behind the popular AI programming artifact Cursor, and OpenAI also participated in the investment. You must know that on Groq, a well-known fast inference acceleration framework, the inference speed of 70BLlama3 is only more than 300 tokens per second. With the speed of Cursor, it can be said that it achieves near-instant complete code file editing. Some people call it a good guy, if you put Curs

China Mobile: Humanity is entering the fourth industrial revolution and officially announced 'three plans” China Mobile: Humanity is entering the fourth industrial revolution and officially announced 'three plans” Jun 27, 2024 am 10:29 AM

According to news on June 26, at the opening ceremony of the 2024 World Mobile Communications Conference Shanghai (MWC Shanghai), China Mobile Chairman Yang Jie delivered a speech. He said that currently, human society is entering the fourth industrial revolution, which is dominated by information and deeply integrated with information and energy, that is, the "digital intelligence revolution", and the formation of new productive forces is accelerating. Yang Jie believes that from the "mechanization revolution" driven by steam engines, to the "electrification revolution" driven by electricity, internal combustion engines, etc., to the "information revolution" driven by computers and the Internet, each round of industrial revolution is based on "information and "Energy" is the main line, bringing productivity development

See all articles