On 3/29/2013 12:38 AM, Paul Gilmartin wrote:
> I have a stage I would like to run immediately on receiving
> a request; however, if it has run within the previous 15
> minutes, it should queue any requests and execute them as a
> batch when the 15 minutes expires.

STREAMSTATE INPUT will tell you if the next record is already waiting.
You'll have to SUSPEND first to give the stream upstage a chance to
write it:

  'streamstate summary'
  Do While rc = 0
    'callpipe *: | take 1 | *:'
    'suspend'
    'streamstate input'
    If rc ¬= 0 then Do
      'callpipe literal +15:00 | delay | hole'
      'peekto'
    End
    'streamstate summary'
  End

I threw in the PEEKTO just in case this is in a feedback loop--wouldn't
want to have two of these stages waiting on each other forever!  If you
want to read the records in as a batch and process them together,
instead of doing this in a separate stage you could save them one by one
in a stem:

  'streamstate summary'
  Do While rc = 0
    'callpipe *: | take 1 | stem batch. append'
    'suspend'
    'streamstate input'
    If rc ¬= 0 then Do
      /* process the batch here, and then: */
      batch.0 = 0
      'callpipe literal +15:00 | delay | hole'
      'peekto'
    End
    'streamstate summary'
  End

¬R

Reply via email to