Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Chapter 4: Building dbQueue Applications [Table of Contents]

Sybase dbQueue User's Guide

[-] Chapter 5: Java Queuing Tool

Chapter 5

Java Queuing Tool

This chapter contains the following topics:

Overview

The Java queuing tool can enqueue and dequeue messages to and from visible dbQueue queues. It runs from a Java-enabled browser (such as Netscape) to access queues in an existing dbQueue system. Its graphical user interface lets you enter data for each field in the selected message type and then enqueue the message. It can also retrieve messages from the selected queues and displays the data. You can reload catalog information if you have reconfigured your system.

The tool accesses an HTML file located in the java subdirectory of the dbQueue release directory.

Requirements

To run the tool, you need:

Using the Java Queuing Tool on Windows NT

The Java queuing tool can connect to a preconfigured demo database or any existing dbQueue queues.

Using the javademo Preconfigured Database on NT

  1. Start the Java queuing tool by double-clicking on the Queuing Applet icon in the dbQueue program group window.

    A SQL Anywhere engine starts for the preconfigured "javademo" datasource and a preconfigured gateway that the queuing tool will use to access the datasource. It also opens a preconfigured javademo.html file in your Java-enabled Netscape browser.

    The "Data Source" list box has one entry ("javademo"). The message types list box has "Coffee" and "Pizza," which are available for the source queue Orders and target queue Dispatch. The data entry fields change to reflect the selected message type.

    See Running the Java Queuing Tool and Using the Interface.

  2. (optional) Examine the javademo entities using Sybase Central. Start Sybase Central by double-clicking the Sybase Central icon in the dbQueue program group window. See Chapter 3, "Using Sybase Central," for more information.

  3. (optional) Click on the javademo icon in the left panel and supply the password "dbq_sa" when the login dialog box appears.

    The Java queuing tool displays three message types ("Coffee," "Pizza," and "Types"), one application database ("javademo"), three queues in that database (Dispatch, Orders, and Demo), one QTM ("qtm"), and one transfer ("Orders_Dispatch").

Using Other Queues and Databases on NT

To start the Java queuing tool to work with other queues:

  1. Make sure the dataserver (or servers) that manages the catalog and queues is running. If you are using a SQL Anywhere database, the gateway should also be running. See Connect to SQL Anywhere.

  2. Use an ASCII editor (such as Notepad) to edit the parameters in the Queue.html file in the %DBQ%\java directory to the values of your server and port. Refer to the instructions in Queue.html. The following sample shows entries in Queue.html for a server named buzz running on port number 5000 accessing the dbq_catalog database:

    <APPLET CODE=Queue.class WIDTH=600 HEIGHT=500>
    <PARAM NAME="server" VALUE="buzz">
    <PARAM NAME="port" VALUE="5000">
    <PARAM NAME="database" VALUE="dbq_catalog">
    </APPLET>
    You may want to save a read-only copy of the Queue.html file as a template.

  3. If you use Netscape, start the Java queuing tool by running the dbqtool.bat script in the %DBQ%\java directory, or by double-clicking the Queuing Applet icon in the dbQueue programming group window. The Netscape executable must be specified in the PATH environment variable.

    If you are not using Netscape, you can:

Connect to SQL Anywhere

To connect to a SQL Anywhere database, you need to use the gateway as follows:

  1. Make an entry in %SYBASE%\ini\SQL.ini for the gateway. You can use the sqledit utility or use an editor to edit the file directly. Set both the "query" and "master" fields. For example, if your database name is dbq_catalog, and it is running on machine spring, the entry would appear as:

        [dbq_catalog]
    query=NLWNSCK,spring,5000
    master=NLWNSCK,spring,5000
    If you use more than one database, you must create a separate entry for each database. Each entry must have a different port number.

  2. Start the gateway utility dbos50.exe. For example, to start the gateway for the dbq_catalog database:

        start dbos50 -d dbq_catalog dbq_catalog
    WARNING! If you plan to use SQL Anywhere, you must create entries for the gateways before adding any dbQueue data sources to your dbQueue domain (either programmatically or by using Sybase Central ). To use this queuing tool, the gateways must be running. The queuing tool contacts the SQL Anywhere databases through these gateways.

Using the Java Tool on UNIX

The Java queuing tool can connect to a preconfigured demo database or any existing dbQueue queues.

Using Scripts to Create a Javademo Database

Run the supplied scripts to create the javademo database in a SQL Server and populate it with a catalog, queues, messages types, and transfers.

  1. Start a Sybase SQL Server and set the DSQUERY environment variable to point to the SQL Server.

  2. Move to the $DBQ/java directory and run javademo_setup. For example:

    cd $DBQ/java
    javademo_setup [password]
    where password is the password for the user sa in the SQL Server. The default password for sa is the ""value.

    javademo_setup installs a javademo database on the server and populates it with sample data. You only need to run javademo_setup once.

    javademo_setup adds the message types "Coffee" and "Pizza," the source queue Orders, the target queue Dispatch, the QTM "qtm," and the transfer "Orders_Dispatch" to the javademo database.

  3. (optional) To perform distributed queuing:

    The QTM allows enqueue operations to the source queue and dequeue operations from the target queue. The QTM "qtm" transfers messages from the source queue Orders to the target queue Dispatch.

  4. Invoke javademo:

    javademo
    The Java queuing tool starts in Netscape and connects to the javademo database. See Running the Java Queuing Tool and Using the Interface.

Using Other Queues and Databases on Solaris

To start the Java queuing tool to work with other datasources and queues:

  1. Make sure the dataserver (or servers) that manages the catalog and queues is running.

  2. Use an ASCII editor (such as vi or emacs) to edit parameters in the Queue.html file in the $DBQ/java directory to the values of the server and port. Refer to the instructions in Queue.html. The following sample shows entries in Queue.html for a server named buzz running on port number 5000 accessing the dbq_catalog database:

    <APPLET CODE=Queue.class WIDTH=600 HEIGHT=500>
    <PARAM NAME="server" VALUE="buzz">
    <PARAM NAME="port" VALUE="5000">
    <PARAM NAME="database" VALUE="dbq_catalog">
    </APPLET>
    You may want to save a read-only copy of the Queue.html file as a template.

  3. If you use Netscape, start the Java queuing tool by running the dbqtool script in the $DBQ/java directory. The Netscape executable must be specified in the PATH environment variable. The script launches Netscape and loads the Java queuing tool.

    If you are not using Netscape, you can:

Running the Java Queuing Tool and Using the Interface

You can enqueue and dequeue messages to the Dispatch queue. If "qtm" is running, you can also enqueue to the Orders queue and dequeue from the Dispatch queue.

Depending on how messages and queues are configured, messages of different types may be enqueued to the same queue. Messages are retrieved in the same order in which they were submitted, regardless of type.

Once you start the tool, you see the dbQueue Queue Interface web page. It contains selections for a Submit Window, a Fetch Window, a Catalog Reload window, datasource, queue, message type, and data fields that correspond to the selected message type.

Figure 5-1: dbQueue Queue Interface web page
raster

To enqueue a message:

  1. Click Submit.

  2. Select a datasource, queue, and message type.

    Data fields corresponding to the selected message type appear.

  3. Enter a value for each data field.

  4. Click Submit to enqueue the message.

    A status window appears showing the status of the enqueue operation. If you are queuing to SQL Anywhere, the status displayed may not be an accurate representation of the actual status because the gateway may filter the return message.

To dequeue a message:

  1. Click Fetch.

  2. Select the datasource and queue.

    Message types corresponding to the selected queue appear and data fields corresponding to the message type appear.

  3. Click Fetch to dequeue a message; the message data appears.

If you made any changes to the system , click on Catalog Reload to apply the changes.


Chapter 4: Building dbQueue Applications [Table of Contents]