× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello Aaron,

You wrote:
>I am working on a program that needs to wait for entries to be put into a
>user defined data queue and process them.  I have read how data queues
>work but I am confused on some things.  What would I specify for a wait
>time if I wanted to process a queue entry as soon as it hits the data
>queue?

Any time you like except zero.  As soon as an entry arrives on the queue
your program will be woken and will start to processs that entry.  Wait
times that are too short will cause a polling loop if you have written the
program to simply continue waiting on the queue.

>Also, once I have my program done that calls API QRCVDTAQ do I just
>submit it to batch and let it run?  It seems that it would just loop and
>take up a lot of processor time??  Or is that where the 'wait time' parm
>comes in?

It will "loop and consume  lot of processor time" only if you wrote it
that way.  A queue wait is an event.  Your job doesn't use any (well not
trackable) CPU while it is waiting for an entry to arrive.  The wait time
parameter works like this:

        If there is an entry on the queue when you call QRCVDTAQ then you
get that entry immediately regardless of the wait time.

        If there are no entries on the queue and the wait time is zero the
call returns immediately with no data.  This is generally the worst thing
you can do in a loop because you will be polling the queue and thus
consuming excess CPU.

        If there are no entries on the queue and the wait time is positive
the call will wait that number of seconds for an entry to arrive.  If an
entry arrives within the wait time then you get it as soon as it arrives.
If an entry does not arrive then the call times-out and returns with no
data.

        If there are no entries on the queue and the wait time is negative
then the call will wait forever for an entry to arrive.  If an entry
arrives while you are waiting then you get it as soon as it arrives.  If
an entry does not arrive then the call never times-out.

        The normal method of using data queues in a batch process is to
wait forever on the queue.  You would also write a 'stop queue' program
that sends a special message to the queue (e.g., **END**).  When the batch
process receives this message it would shut down.

        You can get quite creative with data queues and have the batch
process monitor how fast it is processing queue entries and if it is
falling behind because entries are arriving faster than it can process
them, it could start another copy of itself to process queue entries twice
as fast.  Once the jobs catch up and clear the queue you might have quite
a few jobs waiting on the queue with nothing to do.  In this case you
could use a timed wait and if a job woke up but did not have any data it
could end if it isn't the last job running.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists
   http://www.flybynight.com.au/

   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.