I am building a system that consists of 2 basic processes.

Part 1 is a program that adds elements to a queue. Part 2 is a group of programs that remove elements from the queue.

The queue could be up to 1 million elements in length. Items are added and removed at rates in the region of 1 to 10 per second. For various reasons it would be convenient if we could use mySQL, which is already installed on the server, to handle the queue. There needs be 1 table containing the individual elements in the queue and another table containing 1 or more data lines per entry.

I need some guidance as to a SQL query which will allow me to take an element from the queue, and all the associated data lines, and remove the element or mark it as processed. Obviously it is paramount the same item cannot be removed from the queue multiple times.

Any ideas or pointers? I've looked for information on implementing a FIFO system using a database but couldn't find anyhting.


Edit 2001-07-09 ar0n -- added paragraph tags


In reply to Queues, not the usual problem by rob_smith01

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.