Sun GlassFish Message Queue 4.4 Administration Guide

Configuring a JDBC-Based Data Store

To configure a broker to use a JDBC database, you set JDBC-related properties in the broker’s instance configuration file and create the appropriate database schema. The Message Queue Database Manager utility (imqdbmgr) uses your JDBC driver and the broker configuration properties to create the schema and manage the database. You can also use the Database Manager to delete corrupted tables from the database or if you want to use a different database as a data store. See Database Manager Utility for more information.


Note –

If you use an embedded database, it is best to create it under the following directory:

   
.../instances/instanceName/dbstore/databaseName

If an embedded database is not protected by a user name and password, it is probably protected by file system permissions. To ensure that the database is readable and writable by the broker, the user who runs the broker should be the same user who created the embedded database using the imqdbmgr command.


ProcedureTo Set Up a JDBC-Based Data Store

  1. Set JDBC-related properties in the broker’s instance configuration file.

    The relevant properties are discussed, with examples, in JDBC-Based Persistence Properties and listed in full in Table 17–7. In particular, you must specify a JDBC-based data store by setting the broker’s imq.persist.store property to jdbc.

  2. Place a copy of, or a symbolic link to, your JDBC driver’s .jar file in the Message Queue external resource files directory, depending on how Message Queue was installed (see Appendix A, Distribution-Specific Locations of Message Queue Data):

      IPS packages: IMQ_HOME/lib/ext


      Solaris SVR4 packages: /usr/share/lib/imq/ext


      Linux RPM packages: /opt/sun/mq/share/lib/ext


    For example, if you are using HADB on an IPS package-based installation, the following command copies the driver’s .jar file to the appropriate location:

    cp  /opt/SUNWhadb/4/lib/hadbjdbc4.jar  IMQ_HOME/lib/ext
    

    The following command creates a symbolic link instead:

    ln  -s  /opt/SUNWhadb/4/lib/hadbjdbc4.jar  IMQ_HOME/lib/ext
    
  3. Create the database schema needed for Message Queue persistence.

    Use the imqdbmgr create all command (for an embedded database) or the imqdbmgr create tbl command (for an external database); see Database Manager Utility.

    1. Change to the directory where the Database Manager utility resides, depending on how Message Queue was installed:

        IPS packages: cd IMQ_HOME/bin


        Solaris SVR4 packages: cd /usr/bin


        Linux RPM packages: cd /opt/sun/mq/bin


    2. Enter the imqdbmgr command:

         
      imqdbmgr create all
      

ProcedureTo Display Information About a JDBC-Based Data Store

You can display information about a JDBC-based data store using the Database Manager utility (imqdbmgr) as follows:

  1. Change to the directory where the Database Manager utility resides, depending on how Message Queue was installed:

      IPS packages: cd IMQ_HOME/bin


      Solaris SVR4 packages: cd /usr/bin


      Linux RPM packages: cd /opt/sun/mq/bin


  2. Enter the imqdbmgr command:

       
    imqdbmgr query
    

    The output should resemble the following

    dbmgr query
    
    [04/Oct/2005:15:30:20 PDT] Using plugged-in persistent store:
            version=400
            brokerid=Mozart1756
            database connection url=jdbc:oracle:thin:@Xhome:1521:mqdb
            database user=scott
    Running in standalone mode.
    Database tables have already been created.