XmlBlaster Logo

REQUIREMENT

queue.jdbc.commontable

XmlBlaster Logo


Type NEW
Priority HIGH
Status DEPRECATED
Topic JDBC Plugin which stores all queues on a common table.
Des
cription

This was the default persistence implementation until releas 1.6.4, please read queue.jdbc for migration details.

When using the org.xmlBlaster.util.queue.jdbc.JdbcQueuePlugin XmlBlaster handles jdbc persistent storage by using a pool of tables. When a queue is created, such a table is used to store messages of that queue. When the queue is destroyed, the associated table is put back in the pool of free tables. If there is need for further tables, xmlBlaster automatically adds tables to the pool.

For systems where the programmatical creation of tables on the DB is not allowed, it would become unpractical or even prohibitive to create a sufficient amount of tables for the freetables pool by hand.
For such situations an alternative approach can be used which uses a limited number of tables. This approach is used by the class org.xmlBlaster.util.queue.jdbc.JdbcQueueCommonTablePlugin.

Concept
All necessary information will be contained in one table. The name of the table is configurable with the configuration file. More about that in the configuration section. Lets call the table Entries.

As already said, all entries are put in a common bucket, unaware of which cluster they belong. In many applications this must be avoided. You can isolate the entries on a per cluster basis or on a per cluster-group basis by having defined different names for the different tables.

When you start xmlBlaster for the first time you may want to let it create the necessary table. In other situations you would like to prevent it to be done (for example because lack of authorization). For these purposes you can use the dbAdmin flag

If there is the need to create the tables manually here follows the code to use (note that it is parameterized).

#
# General settings (independent from database implementations)
# 
# ${Entries} XMLBLASTERENTRIES
#
#  For postgres:
#
# ${string}  text
# ${longint} bigint 
# ${int}     integer
# ${boolean} char(1)
# ${blob}    bytea
#
#  For Oracle:
#
# ${string}  VARCHAR(128)
# ${longint} NUMBER(19)
# ${int}     NUMBER(10)
# ${boolean} CHAR(1)
# ${blob}    long raw
#

CREATE TABLE ${Entries} (dataId ${longint},
                         queueName ${string},
                         prio ${int},
                         flag ${string},
                         durable ${boolean},
                         byteSize ${longint},
                         blob ${blob},
                         PRIMARY KEY (dataId, queueName),
     

Configure To activate persistence please add the following to your properties file:
persistence/defaultPlugin=CACHE,1.0
queue/defaultPlugin=CACHE,1.0
useTopicStore=true
     
StoragePlugin[JDBC][1.0]=org.xmlBlaster.util.queue.jdbc.JdbcQueueCommonTablePlugin,\
                         entriesTableName=ENTRIES,\
                         tableNamePrefix=XB,\
                         dbAdmin=true,\
                         configurationIdentifier=mySpecialDB
     
Property default comment
entriesTableName ENTRIES the name postfix for the table containing the entries.
tableNamePrefix XB the name prefix for the table containing the entries. Note that the complete names for the tables are created by adding the tableNamePrefix to the names. So if you specify entriesTableName=ENTRIES and tableNamePrefix=XB_ you will get the name of the table to be XB_ENTRIES.
dbAdmin true if set to true xmlBlaster will try to create tables if needed.
configurationIdentifier $DatabaseMetaData.getDatabaseProductName()$ The ID to assign to this configuration. Its only purpose is to find the correct Mapping declaration for this database configuration. This name must match the name inside the square brackets. If you define configurationIdentifier=myStrangeDB here, then you will need to define the associated mapping: JdbcDriver.mapping[myStrangeDB]=longint=numeric (19),boolean=char(1),blob=image. If you don't define anything here, then the database product name is taken (which you get with DatabaseMetaData.getDatabaseProductName()).
connectionPoolSize 1 the number of connections to the DB (tests showed that a low number gives the best performance).
connectionBusyTimeout 90000 The time to wait in milliseconds until to timeout when waiting for a connection to the DB.
maxWaitingThreads 300 The maximum number of threads waiting for a connection to the DB.
tableNamePrefix xmlBlaster The prefix to use in the tablenames. All tables used will start with the uppercase of the text specified here. Do not choose names which are too long since many DB have a limited tablename length.
maxStatementLength 2048 The maximum SQL statement length supported by this JDBC driver. If the JDBC meta data delivers this information this property is ignored.
enableBatchMode true Tells the driver to make the addition of entries in batch mode, i.e. several entries are added in the same sweep. This can improve performance on some DB's significantly. The drawback is that it could loose performance and create noisy logs in the case you insert several entries and one of them is already in the DB. Then everything would be rolled back and repeated in single mode (we can not save the current state since PostGres implicitly aborts transactions in case of an SQLException is thrown). If the DB used does not support batch mode, then this option is ignored.
cascadeDeleteSupported true Tells the driver that cascade delete is supported. When this is set (default), deleting a queue will delete all entries within the same SQL statement.
nestedBracketsSupported true Tells the driver wether nested brackets are supported or not. It normally is supported.
There is also the need to specify which mapping to use for the conversion from java types to the types used for a particular database. This is done with the JdbcDriver.mapping[xxx] property. The value specified here as xxx is the plugin property configurationIdentifier
JdbcDriver.mapping[myStrangeDB]=string=text,\
                                longint=bigint,\
                                int=integer,\
                                boolean=char(1),\
                                blob=bytea,\
                                pingStatement=SHOW ALL,\
                                blobVarName=blob,\
                                keyAttr=
     
Subproperty default comment
string text The name be used for the java.String type
longint bigint The name be used for the java.Long type (or long)
int integer The name be used for the java.Integer (or int) type
boolean char(1) The name be used for the java.Boolean (or boolean) type (a char is used since oracle does not support boolean)
blob bytea The name be used for the blobs (mapped to byte[])
pingStatement SHOW ALL The SQL stement to use to simulate a ping to the DB
blobVarName blob The name to assign to the table column for the blob. This has been added since the name blob is invalid because it is an internal keyword.
keyAttr (empty string) Additional attributes to the PRIMARY KEY to describe the primary key. Some DB need not null being added here
Note that the separator for the subproperties is a comma (,). If for some reasons you need to use a comma inside the subproperty (for example if you want to define ...,longint=decimal(19,0),..., then you can surround the whole subproperty (important) by a double quote (") as ...,"longint=decimal(19,0)",...

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.

See API org.xmlBlaster.util.queue.I_Queue
See API org.xmlBlaster.util.queue.jdbc.JdbcQueueCommonTablePlugin
See API org.xmlBlaster.util.queue.QueuePluginManager
See API org.xmlBlaster.util.queue.I_QueueEntry
See API org.xmlBlaster.util.qos.storage.QueuePropertyBase
See API org.xmlBlaster.util.I_Plugin
See API org.xmlBlaster.util.Global
See REQ queue
See REQ queue.jdbc
See REQ queue.jdbc.postgres
See REQ queue.jdbc.oracle
See REQ queue.jdbc.firebird
See REQ queue.jdbc.sqlserver
See REQ queue.jdbc.hsqldb
See REQ queue.jdbc.mysql
See REQ queue.jdbc.ldbc

This page is generated from the requirement XML file xmlBlaster/doc/requirements/queue.jdbc.commontable.xml

Back to overview