Simon,

You need to see section "Sample STAX Job 3 - Creating a STAF Handle and
Using it's Queue" in the STAX User's Guide at
http://staf.sourceforge.net/current/STAX/staxug.html#Header_SampleJob3.
This STAX job demonstrates how to create your own STAF handle within a STAX
job and use its queue to get messages.

You're missing the following key point:

You should NOT use the STAX job handle's queue (don't try to get data off
its queue or put data on its queue) as that interferes with the use of the
queue by the STAX service as described in the "Concepts" section,
sub-section "Queues" in the STAX User's Guide.  In  your case, the STAX job
already got the STAF/Process/End notify message off its handle's queue
(which is why you're not seeing it).

You need to create your own STAF handle (instead of using the STAX job's
handle) and specify to have that handle be notified in your PROCESS START
request (e.g.  NOTIFY ONEND HANDLE yourHandleNumber).

Then you can use this newly created handle to submit a QUEUE GET/PEEK
request (with an optional WAIT option with a maximum wait time if desired)
to the QUEUE service using the Java STAFHandle's submit2 method. You can
customize this QUEUE GET/PEEK request to meet your needs.

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




From:   Simon McQueen <s...@prismtech.com>
To:     staf-users@lists.sourceforge.net
Date:   09/24/2010 09:55 AM
Subject:        [staf-users] Trying to PEEK the QUEUE for STAF/Process/End
            events - STAF 3.4.2 / STAX 3.4.3



Hi all,

I'm persisting in my one man suicide mission to asynchronously start
processes and manage them in an ad-hoc manner in STAX without using
<process /> / <process-action /> and am looking to be able to use NOTIFY
ONEND to get access to the returned stdout & err and whatnot once the
process completes.

I've got some simplified test XML here like:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">
<stax>
   <defaultcall function="HelloMain">
   </defaultcall>
   <function name="HelloMain" scope="local" >
     <function-no-args/>
     <sequence>
       <script>
         machine = 'local'
         request = 'START COMMAND java STDERRTOSTDOUT RETURNSTDOUT
NOTIFY ONEND'
       </script>
       <stafcmd>
         <location>machine</location>
         <service>'PROCESS'</service>
         <request>request</request>
       </stafcmd>
       <script>
         # wait a while to ensure completion
         import time
         time.sleep(5)
       </script>
       <script>
         request = 'QUERY HANDLE %s' % (STAFResult)
       </script>
       <stafcmd >
         <location>machine</location>
         <service>'PROCESS'</service>
         <request>request</request>
       </stafcmd>
       <log level="'info'">'The query result: %s' % (STAFResult)</log>
       <stafcmd>
         <location>machine</location>
         <service>'QUEUE'</service>
         <request>'PEEK ALL'</request>
       </stafcmd>
       <log level="'info'">'Peek response RC=%s STAFResult=%s' % (RC,
STAFResult) </log>
     </sequence>
   </function>
</stax>

.... although this doesn't seem to be doing what I want. The RC from the
peek is always 29, indicating nothing in the queue. I *think* what I am
trying to do should be possible because yesterday I (largely by
accident) somehow managed to produce an entry in my user log like:

Peek response RC=0 STAFResult=[{'machine':
'tcp://beatrice.prismtech....@6500', 'user': 'none://anonymous',
'handle': '1', 'staf-map-class-name': 'STAF/Service/Queue/Entry',
'timestamp': '20100923-13:32:04', 'type': 'STAF/Process/End',
'priority': '5', 'handleName': 'STAF_Process', 'message':
{'endTimestamp': '20100923-13:32:04', 'fileList': [{'rc': '0', 'data':
''}], 'key': '1', 'rc': '1', 'handle': '21'}}

... with similar QUEUE PEEK debug code after an async started event had
completed.

Can anyone spot what I'm doing wrong here please ?

Cheers,
--
Simon McQueen
e-mail: mailto:s...@prismtech.com
Tele:   +44-191-497-9966
Web:    http://www.prismtech.com

------------------------------------------------------------------------------

Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to