|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Generating sequence numbers using ESQL |
« View previous topic :: View next topic » |
Author |
Message
|
swaugh |
Posted: Wed Mar 12, 2008 8:49 am Post subject: Generating sequence numbers using ESQL |
|
|
Apprentice
Joined: 15 Jun 2006 Posts: 37
|
hi,
is there any way in esql, we can generate a sequence number that we can maintain and generate regularily.
do we need to use shared variables?
thanks,
swaugh |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Mar 12, 2008 8:57 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You only need to use a shared variable if you need to have the sequence stay unique across invocations of a node or a flow.
If you only need the sequence number to be unique within a node or a flow, then you don't need a shared variable.
You won't likely be able to use ESQL to generate a sequence number that is unique across a broker or between a broker - unless you use the UUID functions...
EDIT: "between brokers", not "between a broker".
And technically, the UUID functions don't produce results that are sequential. But they are unique! _________________ I am *not* the model of the modern major general.
Last edited by jefflowrey on Wed Mar 12, 2008 9:37 am; edited 1 time in total |
|
Back to top |
|
 |
swaugh |
Posted: Wed Mar 12, 2008 9:20 am Post subject: |
|
|
Apprentice
Joined: 15 Jun 2006 Posts: 37
|
|
Back to top |
|
 |
francoisvdm |
Posted: Wed Mar 12, 2008 11:01 am Post subject: |
|
|
Partisan
Joined: 09 Aug 2001 Posts: 332
|
If it is not a super high performance flow, just pop the sequence number in a queue, read it from there for next flow, add 1, pop back _________________ If you do not know the answer or you get the urge to answer with "RTFM" or "Search better in this forum", please refrain from doing so, just move on to the next question. Much appreciated.
Francois van der Merwe |
|
Back to top |
|
 |
chrisc |
Posted: Wed Mar 12, 2008 2:00 pm Post subject: |
|
|
Voyager
Joined: 19 Mar 2006 Posts: 77
|
Francois' suggestion is an interesting one, although it may be difficult (impossible?) to wrap such a thing in a simple procedure in ESQL that could be called from your flow(s). It also has a big disadvantage in that multi-threading your flows wouldn't work, because the counter message wouldn't appear back on the queue until the other thread had committed its transaction.
One technique we have used in the past is just use a database sequence, and use ESQL to retrive the sequence. This has the advantage of working across multiple flows and being both unique and sequential.
If the database doesn't support sequences there are ways of doing the same thing with triggers or stored procedures as well. Just don't do non-atomic SELECT then UPDATE statements to read a value in a table and then update it to +1 or you could get inconsistent results. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|