SQL/MX Queuing and Publish/Subscribe Services

Embedded SQL Examples
HP NonStop SQL/MX Queuing and Publish/Subscribe Services523734-002
3-15
Managing Transactions With the Stream Timeout
Attribute
printf("column name: %s\n", hv_column_name);
printf("message text: %s\n", hv_message_text);
printf("sqlcode: %ld\n", hv_sqlcode);
printf("\n");
}
/* Special handling for stream_timeout exception. */
if (hv_sqlcode == -8006 && num == 1)
{
printf("Stream timeout.\n");
timed_out = TRUE;
return;
}
exit(1);
err_exit:
printf("Error in the error handler. SQLCODE =%d\n", SQLCODE);
exit(2);
}
---------------------------------------------------------------
In the preceding example, the first statement might return a row that is still locked by
the publisher application. In such cases, the second statement might experience
stream timeout before the lock is released. If this happens, the application loops to
retry the first statement after committing the empty transaction. The same row might be
returned again, but if the publisher commits its transaction, it will eventually be
unlocked so that it can be deleted.
Of the two previous examples, the first is certainly simpler to code. It has a
disadvantage in an environment where new rows appear infrequently in the stream,
because a high proportion of the transactions will be empty. Also, if the environment
requires that transactions be very short duration, the first example produces an even
higher rate of empty transactions. The second example does not begin a transaction
until rows are ready to be processed.