Você está na página 1de 4

Event-based database integration

Use a DatabaseInput node to respond to events in a database. For example,


the broker can keep an external system synchronized with a database by sending
updates to the target system whenever data is changed in the database.
The database must record the act that data has changed in an event store,
which is typically a database table. The event store is not the same as the
application data. The ollowing diagram shows the interaction between the
database, event store, and the broker.
!. " database application changes a database table.
#. The database management system $D%&'( records the change in the event
store.
). The broker polls the event store ater the interval speciied in the Polling
interval coniguration setting.
*. +eb'phere, &essage %roker retrieves the new or changed data, and
updates the event store, so that the data is processed only once.
-. +eb'phere &essage %roker processes the data, and ultimately presents it
to the target application, or example '"., web services, or /I/',
Transaction 'erver or z01',. The data can be presented in a dierent
logical and physical ormat, i re2uired.
Implementing
Implementing this scenario involves the ollowing steps3
!. /oniguring the database to record events.
#. Determining the ormat in which the target system must receive the data
rom these new events.
3. /oniguring the broker to detect these events by using
the DatabaseInput node. To conigure theDatabaseInput node,
see /oniguring a DatabaseInput node.
*. /oniguring the rest o the message low to present the data to your target
system in the correct ormat.
The DatabaseInput node
The ollowing diagram shows how the DatabaseInput node works.
+hen the process starts, 4ead5vents checks the event store or new events, which
are then used by %uild&essage to build the message. This message is propagated
to the message low and then 5nd5vent updates the event store to ensure that the
event cannot be processed again. +hen all events have been processed, the broker
calls 4ead5vents to retrieve any events that have been added since the previous
check. I the event store is empty, the broker waits until the polling interval has
expired, and then calls 4ead5vents again. To avoid contention, the check o the
event store is single6threaded.
For each event that is read by 4ead5vents, %uild&essage builds the
message that is propagated to the message low. %uilding the message typically
uses the event data to look up data in the application table. The data rom the
application table is then used to construct the message. +hen %uild&essage ends,
the message is automatically propagated to the message low. +hen the message
is propagated, the broker starts any downstream nodes that are re2uired to process
the message.
"ter the message has been propagated to the message low, 5nd5vent
updates the event store to ensure that the event that has 7ust been processed cannot
be processed again.
The detailed operation o 4ead5vents, %uild&essage, and 5nd5vent are
controlled by 5'89 code. TheDatabaseInput node contains an 5'89 module with
sample code and comments, which you must modiy to suit your re2uirements.
For inormation about modiying the 5'89, see /oniguring a DatabaseInput
node.
Transactions and Scaling
The processes that are completed by the DatabaseInput node are split
across separate transactions. " new transaction is started when 4ead5vents starts.
+hen 4ead5vents ends, this transaction is committed and new events are marked
or processing. %y committing this transaction, any locks put on the database by
5'89 code that is run rom 4ead5vents are released. Then, or each event
received by %uild&essage, a new transaction is started. This new transaction is
committed ater 5nd5vent inishes.
To scale a DatabaseInput node or many events, change the Additional
instances property on theInstances tab rom its deault value o : to the number
o instances that you re2uire. I you are using additional instances, the database
must be conigured so that multiple applications can read dierent rows rom the
application table at the same time. 4ead5vents always runs in single6threaded
mode to avoid database contention, even i you use additional instances. To
improve perormance, 4ead5vents can read multiple events each time it runs, and
these events can be processed at the same time by multiple instances o
%uild&essage. The event store must have a primary key, which 4ead5vents uses
to identiy events that are currently being processed. ;ou do not have to write the
5'89 in 4ead5vents to ilter out events that are currently being processed by the
message low.
http300publib.boulder.ibm.com0inocenter0wmbhelp0v<r:m:0index.7sp=topic>
?#Fcom.ibm.etools.mt.doc?#Fbc)*:*:@.htm

Você também pode gostar