Developing Enterprise Java Applications Using DB2 UDB, Version 7.2


Application development extensions

XML Extender

Extensible Markup Language (XML) is the accepted standard technique of data exchange between applications. An XML document is a tagged document consisting of character data and markup tags. The markup tags are definable by the author of the document. A Document Type Definition (DTD) is used to declare the markup definitions and constraints. The DB2 XML Extender provides a mechanism for programs to manipulate XML data using SQL extensions.

Typically, XML documents are stored as individual files in a file system. The DB2 XML Extender provides an alternative storage and manipulation environment. XML documents can be stored as a single column or as a collection, using a set of columns.

The DB2 XML Extender introduces three new data types: XMLVARCHAR, XMLCLOB, and XMLFILE. The Extender provides UDFs to store, extract and update XML documents stored within a single column. Searching can be performed on the entire XML document or based on structural components using the location path, which uses a subset of the abbreviated syntax defined by the XML Path Language (XPath). Side tables can be used to improve search performance for elements or attributes that are frequently queried.

To facilitate storing XML documents as a set of columns, the DB2 XML Extender provides an administration tool to aid the designer with XML-to-relational database mapping. The Document Access Definition (DAD) is used to maintain the structural and mapping data for the XML documents. The DAD is defined and stored as an XML document, making it simple to manipulate and understand. New stored procedures are available to compose or decompose the document.

MQSeries(R) enablement

A set of MQSeries functions are provided with DB2 Universal Database Version 7.2 to allow DB2 UDB applications to interact with asynchronous messaging operations. This means that MQSeries support is available to applications written in any programming language supported by DB2 UDB. For simplicity, all examples shown in this section are SQL statements. A WebSphere application can utilize these MQSeries SQL statements.

Messaging Styles

MQSeries does not mandate that the messages it transports adhere to a particular structure. XML messages typically have a self-describing message structure. Messages can also be unstructured, requiring user code to parse or construct the message content. Such messages are often semi-structured, that is, they use either byte positions or fixed delimiters to separate the fields within a message.

MQSeries supports three messaging models: datagrams, publish/subscribe (p/s), and request/reply (r/r). Messages sent as datagrams are sent to a single destination with no reply expected. In the p/s model, one or more publishers send a message to a publication service that distributes the message to one or more interested subscribers. Request/reply is similar to datagram, but the sender expects to receive a response. The supplied DB2 MQSeries functions support all three message models.

MQSeries is used in a wide variety of ways. Simple datagrams are exchanged to coordinate multiple applications, exchange information, request services, and provide notification of interesting events. The publish/subscribe style is most often used to disseminate real-time information in a timely manner. The request/reply style is generally used as a simple form of pseudo-synchronous remote procedure call (RPC). More complex models can be constructed by combining these basic styles.

DB2 UDB Version 7.2 provides a new MQSeries Assist wizard. This wizard creates a table function that reads from an MQSeries queue using the MQSeries UDFs, which are also new in DB2 UDB Version 7.2. The wizard can treat each MQSeries message as a delimited string or a fixed length column string. The created table function parses the string according to your specifications, and returns each MQSeries message as a row of the table function. The wizard also allows you to create a view on top of the table function and to preview an MQSeries message and the table function result.

DB2 / MQ Infrastructure

In a basic configuration, as shown in Figure 4, an MQSeries server is located on the database server machine along with DB2 Universal Database. The MQSeries functions are available from a DB2 server and provide access to other MQSeries applications. Multiple DB2 clients can concurrently access the MQSeries functions through the database. The MQSeries operations allow DB2 applications to asynchronously communicate with other MQSeries applications. For instance, the new functions provide a simple way for a DB2 application to publish database events to remote MQSeries applications, initiate a workflow through the optional MQSeries Workflow product, or communicate with an existing application package with the optional MQSeries Integrator product.

Figure 4. Basic DB2/MQ configuration


Basic DB2/MQ Configuration

When MQSeries support is installed as part of DB2 Universal Database, a configuration script automatically establishes a default configuration that client applications can use with no further administrative action. The default configuration enables application programmers to get started quickly and provides a simpler development interface.

Messaging examples

The following SQL statement sends a basic message using the default configuration:

   values MQSEND('simple message')

This will send the message simple message to the MQSeries queue manager and queue specified by the default configuration.

The MQSeries functions provided with DB2 Universal Database are based on the Application Messaging Interface (AMI). AMI supports the use of an external configuration file, called the AMI Repository, to store configuration information. The default configuration includes an MQSeries AMI Repository configured for use with DB2 UDB. For more information, refer to: http://www-3.ibm.com/software/ts/mqseries/api/.

Service points and policies are two key concepts in MQSeries AMI, carried forward into the DB2 UDB MQSeries functions. A service point is a logical endpoint from which a message can be sent or received. In the AMI repository, each service point is defined with an MQSeries queue name and queue manager. Policies define the quality-of-service options that should be used for a given messaging operation. Key qualities of service include message priority and persistence. Default service points and policy definitions are provided and may be used by developers to further simplify their applications. The previous example can be rewritten as follows to explicitly specify the default service point and policy name:

   values MQSEND('DB2.DEFAULT.SERVICE',
   'DB2.DEFAULT.POLICY', 'simple message')

Queues can be serviced by one or more applications at the server where they reside. In many configurations, multiple queues will be defined to support different applications and purposes. For this reason, it is often important to define different service points when making MQSeries requests. This is demonstrated in the following example.

   values MQSEND('ODS_Input', 'simple message')

Note that in this example, the policy is not specified, so the default policy will be used.

For further information:

http://www.software.ibm.com/data/integration/MQSeries

Net.Data(R)

Net.Data is an application that connects Web applications to DB2 Universal Database. It now provides XML support which allows you to generate XML tags as output from your Net.Data macro, instead of manually entering the tags. You can also specify an XML style sheet (XSL) to be used to format and display the generated output.

Net Search Extender

The Net Search Extender (not provided with UDE Version 7.2) uses an indexing technique, known as n-gram index, to provide a new high speed text search extender. There are many uses for this extender in the area of Web applications, as text fields are commonly queried by end-users. Finding relevant documents based on text field indexes can improve Web user satisfaction. Any columns based on CHAR, VARCHAR, or LONG VARCHAR can be indexed using an n-gram index. When the index has been created and activated, searches can be performed using a new stored procedure. Active indexes are stored in shared memory to optimize search performance.

Spatial Extender

The Spatial Extender (not provided with UDE Version 7.2) allows users to integrate spatial data into their queries. It supports spatial types to model real-world entities such as the location of customers, boundaries of parks, and paths of cable lines.

DB2 Integrated Web Services Tutorial

A new DB2 tutorial, called eVideoCentral, is available for download at http://www.ibm.com/software/data/developer/samples/evideo. The DB2 eVideoCentral tutorial gives a sample solution for a company that provides business services to another company over the web. This concept is known as a Business-to-Business application. The eVideoCentral tutorial demonstrates the integration of DB2, WebSphere, and MQSeries. Many technologies are used to design and build eVideoCentral, including: IBM's WebSphere Application Server, VisualAge for Java, and the DB2 XML Extender interaction tool. A set of centralized services for individual retail video stores is accessed via Simple Object Access Protocol (SOAP) (see http://www.w3.org/2000/xp/).

SOAP is a lightweight protocol for exchanging information in a decentralized, distributed environment. It is an XML-based protocol that consists of three parts:

SOAP services can provide a mechanism for one company to access DB2 services from another company.

The eVideoCentral tutorial demonstrates the design, development, and implementation of simple data repository (insertion/modification) and query services. The query services use the existing DB2 XML Extender. The first version of eVideoCentral is provided via the web, and it includes: Java Servlets, JSP (Java Server Pages), schema for the DB2 database objects, and the accompanying tutorial documentation.


[ Top of Page | Previous Page | Next Page | Table of Contents ]