SQL/MX Queuing and Publish/Subscribe Services

Examples
HP NonStop SQL/MX Queuing and Publish/Subscribe Services523734-002
B-2
Scenario 1. The Quotes Channel
Scenario 4. Fetching Contract Data is an example of a stream that is joined with
another table to provide additional information. This scenario illustrates using the value
of the contract number in the invoice stream as the condition for a left join operation
with the contracts table.
This scenario also demonstrates the use of the MATERIALIZE compiler directive to
ensure that rows inserted into the contracts table after a cursor has been opened on
the stream of invoices are available to be joined.
Scenario 5. The Shipping Application is the example that integrates features of the
previous scenarios and shows three important usage patterns:
The application uses partitioned queues to route rows in a transparent manner to a
particular partition of a table to balance the load across nodes in a cluster. This
strategy is often used for building scalable queuing applications.
The application uses the clustering key of a table to define the order in which to
process related rows. Rows that are related are given the same user-defined key
prefix. The application generates a consistently increasing sequence number that it
appends to this key. As a consequence, related rows are stored in the order of
their sequence numbers. The subscribing application uses an ORDER BY clause
on the clustering key to process rows in the desired order.
The application uses a cursor-declared WITH HOLD and commits transactions
while the cursor remains opened. This strategy provides better concurrency for the
many SQL sessions that might be accessing the database, compared to the
alternative of allowing the transaction to remain uncommitted for long periods of
time. It also provides better performance for the application that is committing the
transaction with the holdable cursor, compared to closing and reopening the cursor
after every commit.
For the SQL/MP DDL and the SQL/MX DML that creates and populates the shipping
database used for this scenario, see Appendix A, The Shipping Database.
Scenario 1. The Quotes Channel
A stock exchange publishes stock quotes to its brokers. One or more applications
subscribe to the quote channel to receive these stock quotes.
The Quotes Table
In this scenario, the quote channel is a regular key-sequenced SQL table. The rows
are stored in the order received by the Data Access Manager. The Data Access
Manager guarantees that rows are appended at the end of the table because the
consistently increasing system-generated key, the SYSKEY, determines the storage
order of the rows in the table.