Correct, you cannot use a static handle for <stafcmd> elements in a STAX
job. If you want to queue messages to a process, then the recommended
method is to use the <process-action> element .
Receiving queued messages within the STAX job itself is not possible. See
the following thread for more information and a possible alternative
approach: http://sourceforge.net/forum/message.php?msg_id=3837920
David Bender
STAF/STAX Development
(512-286-5315)
IBM Austin Bldg. 903-5B002
Internet: bda...@us.ibm.com
dudeja.ra...@gmail.com
01/30/2009 10:45 AM
To
David Bender/Austin/i...@ibmus
cc
Subject
Re: [staf-users] Unable to use Static Handle with the consecutive commands
in a STAX job file
Hi David,
Thanks for the suggestion. The process element does not pose any great
problem to me rather it is STAFCMD elements in the STAX jobs that are not
using the static handle.
My code is as follows: (The statement in bold letters is actually giving
me RC: 29 error.
<script>
from com.ibm.staf import *
STAXMessageLog = 1
STAXLogMessage = 1
handle1 = STAFHandle("MyApplication")
result = handle1.submit2("local", "HANDLE", "CREATE HANDLE NAME
MyStaticHandleName")
staticHandleNumber = int(result.result)
handle = STAFHandle(staticHandleNumber)
handle = handle.handle
</script>
<function name="startHere">
<sequence>
<stafcmd>
<location>'local'</location>
<service>'PROCESS'</service>
<request>
'START COMMAND python STDIN
"C:/workspaces/test-workspace-xml/testProject1/src/TestSuite1/PyInt.py"'
</request>
</stafcmd>
<if expr="RC == 0">
<log>handle</log>
<else>
<log>'RC = %s, STAFResult = %s' %(RC,
STAFResult)</log>
</else>
</if>
<!-- Inform Python about this static handle by setting a STAF
env. variable -->
<stafcmd name="'Set STAF ENV var'">
<location>'local'</location>
<service>'VAR'</service>
<request>'SET SHARED VAR PY_STATIC_HANDLE=%s'
%(handle)</request>
</stafcmd>
<if expr="RC == 0">
<log>'Handle shared'</log>
<else>
<log>'Could not share handle, RC = %s, STAFResult =f
%s' %(RC, STAFResult)</log>
</else>
</if>
<!-- ************ Queue WAIT REQUEST ************ -->
<stafcmd name = "'Queue messages'">
<location>'local'</location>
<service>'QUEUE'</service>
<!-- 'QUEUE HANDLE %s MESSAGE "WAIT"' %(handle) -->
<request>
'QUEUE PRIORITY 1 HANDLE %s MESSAGE "HELLO"' %(handle)
</request>
</stafcmd>
<if expr="RC == 0">
<log>'REQUEST "WAIT" Queued'</log>
<else>
<log>'RC = %s, STAFResult = %s' %(RC,
STAFResult)</log>
</else>
</if>
<!-- WAIT on EVENT -->
<stafcmd name = "'Wait on Event'">
<location>'local'</location>
<service>'SEM'</service>
<request>'WAIT EVENT RESPONSE1/Ready'</request>
</stafcmd>
<log>'Got Event'</log>
<!-- Get Message from Queue -->
<stafcmd name = "'Queue messages'">
<location>'local'</location>
<service>'QUEUE'</service>
<request>'GET HANDLE %s' %(handle)</request>
</stafcmd>
<if expr="RC==0">
<log>'Got Response %s' %(STAFResult)</log>
<else>
<log>'Response: RC = %s, STAFResult = %s' %(RC,
STAFResult)</log>
</else>
</if>
<log>'Got RESPONSE for "WAIT"'</log>
</sequence>
</function>
</stax>
Thus,
<stafcmd name = "'Queue messages'">
<location>'local'</location>
<service>'QUEUE'</service>
<request>'GET HANDLE %s' %(handle)</request>
</stafcmd>
So, I expect if this stafcmd is some way can use the static handle created
above then this could resolve my problem.
Thanks,
Rajat
On Fri, Jan 30, 2009 at 3:41 PM, David Bender <bda...@us.ibm.com> wrote:
I think you may want to just use the <process-action> element within your
<process> element, so that you can interact with the process. Here is an
example from the STAX User' Guide <process> section (
http://staf.sourceforge.net/current/STAX/staxug.html#Header_Process):
In the following example of a process element, a process-action element is
specified. The process-action task will be executed after the process
starts.
<script>
machName = 'local'
className = 'com.ibm.staf.service.stax.TestProcess'
msg = 'Data being sent to the Process Queue after it starts executing'
</script>
<process name="'aProcess'">
<location>machName</location>
<command>'java'</command>
<parms>className</parms>
<process-action>
<sequence>
<stafcmd>
<location>machName</location>
<service>'QUEUE'</service>
<request>'QUEUE HANDLE %s MESSAGE %s' % (STAXProcessHandle,
msg)</request>
</stafcmd>
</sequence>
</process-action>
</process>
David Bender
STAF/STAX Development
(512-286-5315)
IBM Austin Bldg. 903-5B002
Internet: bda...@us.ibm.com
dudeja.ra...@gmail.com
01/30/2009 09:02 AM
To
staf-users@lists.sourceforge.net
cc
Subject
[staf-users] Unable to use Static Handle with the consecutive commands in
a STAX job file
Hi,
I've the WindowsXP and STAF3.3.1.
I'm trying to create a static handle inside a STAX job which I want it to
be shared across all the consecutive STAF commands used in <stafcmd>
elemement and also across the process created in <process> element.
Though, I got some success by creating this Static handle and having it
shared across the new process. But, I'm not finding any way to make it
used by the consecutive <stafcmd> elements. These <stafcmd> are queueing
some messages to the process created before.
So far, I used the following methods to create the static handle:
1.
<stafcmd>
<location>'local'</location>
<service>'HANDLE'</service>
<request>'CREATE HANDLE NAME "TestHandle1"'</request>
</stafcmd>
2.
<stafcmd>
<location>'local'</location>
<service>'PROCESS'</service>
<request>
'START COMMAND python STATICHANDLENAME "PyHANDLE2" STDIN
"C:/workspaces/test-workspace-xml/testProject1/src/TestSuite1/PyInt.py"'
</request>
</stafcmd>
3.
<script>
from com.ibm.staf import *
STAXMessageLog = 1
STAXLogMessage = 1
handle1 = STAFHandle("MyApplication")
result = handle1.submit2("local", "HANDLE", "CREATE HANDLE NAME
MyStaticHandleName")
staticHandleNumber = int(result.result)
handle = STAFHandle(staticHandleNumber)
handle = handle.handle
</script>
Any help is highly appreciated.
Thanks,
Rajat
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
--
Regrads,
Rajat
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users