> > Recently i came across a peculiar problem we have several transactions
> > which required sequence number , now this number has to be generated and
> > handed out fast enough!!! So it kind of rules out putting it in a db and
> > accessing it!!!
One common and effective solution is to form the sequence number from
two parts, i.e, a "high" value and a "low" value. Suppose the sequence
number is a ten digit number, then one can form them by using two five
digit values:
sequence = HHHHHLLLLL
We can use the database facilities for the "high" value, which can
be done sparingly, e.g., once per server start. The "low" value can
be simply incremented at each request, without any database access.
In this way, we can guarantee that the sequence numbers are unique,
even across restarts and even with a cluster of services accessing
the same database (each will have a different "high" value.) At the
same time, the vast majority of requests can be fulfilled extremely
quickly by simple increment.
One thing to look out for is the overflow of the "low" value. If the
sequence function detects that the "low" value will overflow, simply
acquire another "high" value from the database.
You can use different ways to form the sequence number from the two
values other than simple concatenation.
Regards,
-Ade Barkah
--
Toronto TDC -- www.mobshop.com -- It's Better Together(sm)
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]