SQL/MX Queuing and Publish/Subscribe Services
Introduction
HP NonStop SQL/MX Queuing and Publish/Subscribe Services—523734-002
1-2
Why Use Publish/Subscribe?
of extra performance costs and application complexity. Figure 1-1 shows the 
processing required.
If you simply started many instances of the application in an attempt to make this 
application scalable, they would conflict with each other. As one instance held a lock 
on the next invoice that needed processing, the others would have to wait. To avoid 
conflict, you would have to devise a logical partitioning scheme so each instance 
processed a subset of the invoices, adding complexity to the application and the 
database schema. 
Publish/Subscribe services provides solutions for each of these problems:
•
Rather than polling for changes to the invoice table, the application can use stream 
access mode. Stream access mode changes the behavior of the table: an attempt 
to fetch a row blocks, if necessary, until more rows are available. The application 
code becomes simpler and performs better.
•
Instead of using a positioned UPDATE to mark the row as processed, the 
application can use a special type of statement, an embedded UPDATE, to select 
Figure 1-1. Invoice Processing Without Publish/Subscribe
Fetch
invoice
EOF?
Update
invoice
Close cursor
Sleep
Yes
No
Open cursor
VST002.vsd










