XmlBlaster Logo

REQUIREMENT

contrib.dbwriter

XmlBlaster Logo


Type NEW
Priority HIGH
Status CLOSED
Topic DbWriter writes to a Database entries received as XmlBlaster Messages. It is the ideal sink for its counterpart DbWatcher.
Des
cription

DbWriter overview

DbWriter is a little framework of plugins which writes to a Database messages which have been published either by the DbWatcher or following its message content xml-syntax. DbWriter is extendable through a set of plugin interfaces. For standard cases we provide useful plugins.

DbWriter may be useful when running xmlBlaster to integrate legacy applications where data needs to be writter to a database. Typical uses are for example database partial- or complete replication with- or without modification/manipulation.

The Message Content is an XML Representation of the JDBC ResultSet of a query. Its syntax if fully compatible with the syntax generated by the DbWatcher. In fact this interchange format is the contract between these two plugin frameworks. This contract is defined in the DbWatchwer/DbWriter Contract XSD Schema

Now that you know what DbWriter can do for you we should look into its design.

DbWriter design

DbWriter makes use of a set of interfaces. Some of them are shared with the DbWatcher (as for example I_ChangePublisher, I_DbPool and I_Info), while others as the I_Parser and I_Writer are exclusive for the DbWriter. Additionally, to make it easier for the user, there is a set of info objects encapsulating the XML Message content as a set of java classes. These classes are defined in the info package.

  1. I_Parser How has the content of the messages to be parsed ?
    Normally you should not really bother for this, one single implementation should be enough for the most use cases. The default implementation is org.xmlBlaster.contrib.dbwriter.Writer
  2. I_Writer How shall the jdbc operation be performed ?
    There is a simple default implementation providing the basic functionality. This is the DefaultWriter. For more complex or specific operations you should write your own implementation.
Configure

The plugin is configured in the xmlBlasterPlugins.xml configuration file. If you run DbWatcher outside of xmlBlaster the I_Info interface must return those settings.

Id (name) Type Manda tory Default value Comment
dbPool.class String yes org.xmlBlaster.contrib.db.DbPool Configures your implementation of interface I_DbPool.
mom.class String yes org.xmlBlaster.contrib.MomEventEngine Configures your implementation of interface I_ChangePublisher
parser.class String yes org.xmlBlaster.contrib.dbwriter.SqlInfoParser Configures your implementation of interface I_Parser
dbWriter.writer.class String yes org.xmlBlaster.contrib.dbwriter.Writer Configures your implementation of interface I_Writer
jdbc.drivers String yes null For example oracle.jdbc.driver.OracleDriver, the database specific driver jar file which contains the above class must be in the class path.
db.url String yes null For example jdbc:oracle:thin:@localhost:1521:orcl.
db.user String yes null The database user login name.
db.password String yes null The database password.

If you use the default configuration for mom.class, then the following configuration attributes may/shall be used:

Id (name) Type Manda tory Default value Comment
mom.subscriptions String no null This is a comma separated list of labels identifying a subscription to be done. For every entry specified here, there must be a corresponding attribute mom.subscribeQos[...] and mom.subscribeKey[...]. So if you specified mom.subscriptions=someTopic, then there must be an attribute mom.subscribeQos[someTopic] and an attribute mom.subscribeKey[someTopic] defined.
mom.subscribeKey[...] String no null This is an xml literal (better to wrap it with CDATA) describing the subscribeKey to be used for the given label. This is mandatory if you specified a label in mom.subscriptions. If you don't do it, you will get an exception when initializing. For every mom.subscribeKey, there must be a mom.subscribeQos counterpart.
mom.subscribeQos[...] String no null This is an xml literal (better to wrap it with CDATA) describing the subscribeQos to be used for the given label. This is mandatory if you specified a label in mom.subscriptions. If you don't do it, you will get an exception when initializing. For every mom.subscribeQos, there must be a mom.subscribeKey counterpart.
mom.connectQos String no null This is an xml literal (better to wrap it with CDATA) describing the connectQos. If you specify null here, then the connectQos will be constructed out of other configuration attributes. maxSession is set to whatever configured in mom.maxSessions, retries for connection and callback are set to -1 (failsafe mode), dispatcherPlugin (if any) to what specified by mom.dispatcherPlugin. The session timeout is set to zero (will never die).
mom.loginName String no dbWriter/1 The loginName or session name to be used.
mom.password String no secret The password to use for this mom connection.
mom.dispatcherPlugin String no null The dispatcher plugin name to use (type/version)
mom.maxSessions int no 100 The maximum number of sessions to allow for this subject.

NOTE: Configuration parameters are specified on command line (-someValue 17) or in the xmlBlaster.properties file (someValue=17). See requirement "util.property" for details.
Columns named Impl tells you if the feature is implemented.
Columns named Hot tells you if the configuration is changeable in hot operation.

Todo

Port testsuite to run with HSQLDB and MS-SQLServer, currently the SQL statements from the testsuite are Oracle specific, currently you need a running Oracle, a running xmlBlaster and start the tests separately:

java -Ddb.password=secret junit.swingui.TestRunner -noloading org.xmlBlaster.test.contrib.dbwatcher.TestResultSetToXmlConverter

java -Ddb.password=secret junit.swingui.TestRunner -noloading org.xmlBlaster.test.contrib.dbwatcher.TestTimestamp

Add other I_ChangeDetector plugins which scale better for tables with huge amount of entries.

See API org.xmlBlaster.contrib.dbwriter.DbWriter
See API org.xmlBlaster.contrib.dbwriter.I_Parser
See API org.xmlBlaster.contrib.dbwriter.I_Writer
See API org.xmlBlaster.contrib.dbwriter.info.SqlInfo
See API org.xmlBlaster.contrib.dbwatcher.DbWatcher
See REQ engine.runlevel
See REQ contrib.dbwatcher
See TEST org.xmlBlaster.test.contrib.dbwriter.TestRecordParsing

This page is generated from the requirement XML file xmlBlaster/doc/requirements/contrib.dbwriter.xml

Back to overview