PHP or Toolkit blocking application

Post Reply
zend6388
Posts: 5
Joined: Mon Jan 05, 2015 3:06 pm

PHP or Toolkit blocking application

Post by zend6388 » Fri Feb 05, 2016 4:42 pm

Hey Everyone,

We are in the process of porting Point of Sale Green Screen user interfaces to Web. We are using PHP and the PHP Toolkit to allow us to tie in to the same RPG procedures used to power the terminal Green Screens. One of the features we are currently building into the application is tendering out a sale using an external signature capture device.

On the whole we have been successful, but we have a major issue. As all procedures and jobs are run under a single user running an instance of the Toolkit anytime someone invokes the procedure to activate the Signature Capture device it slows or blocks users in other parts of the application needing the Toolkit to run other procedures.

Effectively, what we are doing is opening a connection with the Sig Cap device through the Toolkit and the PHP waits for a response back from the Signature Capture pad while the user does the actual credit card processing. We believe the problem to be with the PHP not being multi-threaded. But we wanted to check and see if anyone else had come across a similar situation where they needed multiple users connecting to the same, or other, procedures concurrently.

Thanks!

zend6388
Posts: 5
Joined: Mon Jan 05, 2015 3:06 pm

Re: PHP or Toolkit blocking application

Post by zend6388 » Mon Feb 08, 2016 6:07 pm

Added support ticket# 56277.

aseiden
Posts: 875
Joined: Thu Apr 09, 2009 5:45 pm

Re: PHP or Toolkit blocking application

Post by aseiden » Tue Feb 09, 2016 3:52 am

You didn't show any code, but are you using a single "stateful" toolkit job (the same InternalKey value every time) to serve all requests? That could certainly slow things down. Let me know. It's important to use multiple jobs, either through stateless mode (easiest) or multiple stateful jobs.

(I see you also have a Zend support request, but feel free to reply here, since you started the thread.)

Best,
Alan Seiden
alanseiden.com

zend6388
Posts: 5
Joined: Mon Jan 05, 2015 3:06 pm

Re: PHP or Toolkit blocking application

Post by zend6388 » Tue Feb 09, 2016 2:45 pm

Hi Alan -

Thanks for the reply. Looks like that was the culprit. We made a quick change to stateless and we were able to process the transactions as expected. Here's the code we're now using:

Code: Select all

function __construct()
    {
        $config = new Config\Config();

        $this->conn = ToolkitService::getInstance($config->systemname, $config->username, $config->password, 'ibm_db2', true);

        $this->conn->setOptions(array(
            'dataStructureIntegrity' => true,
            'arrayIntegrity' => true
        ));

        $this->conn->setToolkitServiceParams(array(/*'InternalKey'=>'/tmp/MPOSSTAG'*/ 'stateless' => true));
    }
We need to perform testing, but I think we're on the right track.

Thanks for your help!

- Michael

aseiden
Posts: 875
Joined: Thu Apr 09, 2009 5:45 pm

Re: PHP or Toolkit blocking application

Post by aseiden » Tue Feb 09, 2016 3:44 pm

Excellent, Michael. It's the right approach to use stateless mode.

You can streamline your code by moving the stateless element to setOptions():

Code: Select all

$this->conn->setOptions(array(
            'dataStructureIntegrity' => true,
            'arrayIntegrity' => true,
            'stateless' => true
        ));
and then remove setToolkitServiceOptions (older method name).

Congratulations!

Alan Seiden
alanseiden.com

jord2931
Posts: 3
Joined: Tue Feb 09, 2016 6:37 pm

Re: PHP or Toolkit blocking application

Post by jord2931 » Tue Feb 09, 2016 6:46 pm

Hey Alan,

I work with Michael on the PHP implementation of the application. We set the toolkit options to stateless and updated the setOptions method:

Code: Select all

    function __construct()
    {
        $config = new Config\Config();

        $this->conn = ToolkitService::getInstance($config->systemname, $config->username, $config->password, 'ibm_db2', true);

        $this->conn->setOptions(array(
            'dataStructureIntegrity' => true,
            'arrayIntegrity' => true,
            'stateless' => true
        ));

    }
I've been doing some follow-up tests and I wanted to make sure I was understand the behavior correctly. It looks like we use either the internalKey or stateless but not both together. Is that correct?

Is there any performance concerns using one over the other?

aseiden
Posts: 875
Joined: Thu Apr 09, 2009 5:45 pm

Re: PHP or Toolkit blocking application

Post by aseiden » Tue Feb 09, 2016 10:52 pm

Stateless tells the toolkit to use existing DB2 jobs (QSQSRVR). Simplest approach.
Stateful tells the toolkit to use separate jobs (named XTOOLKIT by default). These need to be managed somewhat. InternalKey provides a unique identifier for the jobs.

For your situation, stateless will perform well.

Alan Seiden
alanseiden.com

jord2931
Posts: 3
Joined: Tue Feb 09, 2016 6:37 pm

Re: PHP or Toolkit blocking application

Post by jord2931 » Wed Feb 10, 2016 5:46 pm

Thanks Alan,

So far through our testing running everything as stateless has solved our issue. One thing that we were observing was that if a stateful toolkit instance was kicked off, the next stateless call still seemed to use the the active instance. Everything still appears to be working as expected but this is what our logs show.

Code: Select all

Creating new conn with database: '*LOCAL', user or i5 naming flag: 'misjja', transport: 'ibm_db2', persistence: ''
Going to create a new db connection at 2016-02-09 11:14:40.
Did create a new db connection in 0.022060 seconds.
Exec start: 2016-02-09 11:14:40
Version of toolkit front end: 1.5.0
IPC: '/tmp/Toolkit'. Control key: *cdata *sbmjob(ZENDSVR6/ZSVR_JOBD/XTOOLKIT)
Stmt: call ZENDSVR6.iPLUG512K(?,?,?,?) with transport: ibm_db2
Input XML: <?xml version="1.0" encoding="ISO-8859-1" ?><script><diag info='joblog' /></script>
Output XML: <?xml version="1.0" encoding="ISO-8859-1" ?><script><diag info='joblog'><version>XML Toolkit 1.9.1</version>
<jobinfo>
<jobipc>/tmp/Toolkit</jobipc>
<jobipcskey>011549A5</jobipcskey>
<jobname>XTOOLKIT</jobname>
<jobuser>MISJJA</jobuser>
<jobnbr>083418</jobnbr>
<jobsts>*ACTIVE</jobsts>
<curuser>MISJJA</curuser>
<ccsid>37</ccsid>
<dftccsid>37</dftccsid>
<paseccsid>0</paseccsid>
<langid>ENU</langid>
<cntryid>US</cntryid>
<sbsname>ZENDSVR6</sbsname>
<sbslib>ZENDSVR6</sbslib>
<curlib></curlib>
<syslibl>QSYS QSYS2 QUSRSYS QHLPSYS MCUTILS</syslibl>
<usrlibl>QGPL QTEMP NEWSYS DBU10</usrlibl>
<jobcpffind>see log scan, not error list</jobcpffind>
</jobinfo>
<joblogscan>
<joblogrec>
<jobcpf>CPF1124</jobcpf>
<jobtime><![CDATA[02/09/16  11:14:40.372723]]></jobtime>
<jobtext><![CDATA[Job 083418/MISJJA/XTOOLKIT started on 02/09/16 at 11:14:40 Job 083418/MISJJA/XTOOLKIT submitted.]]></jobtext>
</joblogrec>
<joblogrec>
<jobcpf>*NONE</jobcpf>
<jobtime><![CDATA[02/09/16  11:14:40.372723]]></jobtime>
<jobtext><![CDATA[CALL PGM(ZENDSVR6/XMLSERVICE) PARM('/tmp/Toolkit')]]></jobtext>
</joblogrec>
</joblogscan>
<joblog job='XTOOLKIT' user='MISJJA' nbr='083418'>
<![CDATA[5770SS1 V7R1M0 100423                        Display Job Log                        AVFDEV   02/09/16 11:14:40          Page    1
  Job name . . . . . . . . . . :   XTOOLKIT        User  . . . . . . :   MISJJA       Number . . . . . . . . . . . :   083418
  Job description  . . . . . . :   ZSVR_JOBD       Library . . . . . :   ZENDSVR6
MSGID      TYPE                    SEV  DATE      TIME             FROM PGM     LIBRARY     INST     TO PGM      LIBRARY     INST
CPF1124    Information             00   02/09/16  11:14:40.370452  QWTPIIPP     QSYS        04C0     *EXT                    *N
                                     Message . . . . :   Job 083418/MISJJA/XTOOLKIT started on 02/09/16 at 11:14:40
                                       in subsystem ZENDSVR6 in ZENDSVR6. Job entered system on 02/09/16 at
                                       11:14:40.
CPI1125    Information             00   02/09/16  11:14:40.370921  QWTPCRJA     QSYS        0110     *EXT                    *N
                                     Message . . . . :   Job 083418/MISJJA/XTOOLKIT submitted.
                                     Cause . . . . . :   Job 083418/MISJJA/XTOOLKIT submitted to job queue
                                       ZSVR_JOBQ in ZENDSVR6 from job 074594/QUSER/QSQSRVR. Job
                                       083418/MISJJA/XTOOLKIT was started using the Submit Job (SBMJOB) command
                                       with the following job attributes: JOBPTY(5) OUTPTY(5) PRTTXT()
                                       RTGDTA(QCMDB) SYSLIBL(QSYS       QSYS2      QUSRSYS    QHLPSYS    MCUTILS)
                                       CURLIB(*CRTDFT) INLLIBL(QGPL       QTEMP      NEWSYS     DBU10)
                                       INLASPGRP(*NONE) LOG(4 00 *NOLIST) LOGCLPGM(*YES) LOGOUTPUT(*JOBEND)
                                       OUTQ(/*DEV) PRTDEV(PRT01) INQMSGRPY(*RQD) HOLD(*NO) DATE(*SYSVAL)
                                       SWS(00000000)  MSGQ(QUSRSYS/MISJJA) CCSID(37) SRTSEQ(*N/*HEX) LANGID(ENU)
                                       CNTRYID(US) JOBMSGQMX(64) JOBMSGQFL(*WRAP) ALWMLTTHD(*NO) SPLFACN(*KEEP)
                                       ACGCDE(70001).
*NONE      Request                      02/09/16  11:14:40.372723  QWTSCSBJ                 *N       QCMD        QSYS        0195
                                     Message . . . . :  -CALL PGM(ZENDSVR6/XMLSERVICE) PARM('/tmp/Toolkit')
]]>
</joblog>
</diag>
</script>
Exec end: 2016-02-09 11:14:40. Seconds to execute: 0.36353302001953.
 
Creating new conn with database: '*LOCAL', user or i5 naming flag: 'MPOSDEV', transport: 'ibm_db2', persistence: '1'
Going to create a new db connection at 2016-02-09 11:14:41.
Did create a new db connection in 0.010866 seconds.
Exec start: 2016-02-09 11:14:41
Version of toolkit front end: 1.5.0
IPC: '/tmp/Toolkit'. Control key: *cdata *sbmjob(ZENDSVR6/ZSVR_JOBD/XTOOLKIT)
Stmt: call ZENDSVR6.iPLUG512K(?,?,?,?) with transport: ibm_db2
Input XML: <?xml version="1.0" encoding="ISO-8859-1" ?><script><diag info='joblog' /></script>
Output XML: <?xml version="1.0" encoding="ISO-8859-1" ?><script><diag info='joblog'><version>XML Toolkit 1.9.1</version>
<jobinfo>
<jobipc>/tmp/Toolkit</jobipc>
<jobipcskey>011549A5</jobipcskey>
<jobname>XTOOLKIT</jobname>
<jobuser>MISJJA</jobuser>
<jobnbr>083418</jobnbr>
<jobsts>*ACTIVE</jobsts>
<curuser>MISJJA</curuser>
<ccsid>37</ccsid>
<dftccsid>37</dftccsid>
<paseccsid>0</paseccsid>
<langid>ENU</langid>
<cntryid>US</cntryid>
<sbsname>ZENDSVR6</sbsname>
<sbslib>ZENDSVR6</sbslib>
<curlib></curlib>
<syslibl>QSYS QSYS2 QUSRSYS QHLPSYS MCUTILS</syslibl>
<usrlibl>QGPL QTEMP NEWSYS DBU10</usrlibl>
<jobcpffind>see log scan, not error list</jobcpffind>
</jobinfo>
<joblogscan>
<joblogrec>
<jobcpf>CPF1124</jobcpf>
<jobtime><![CDATA[02/09/16  11:14:40.372723]]></jobtime>
<jobtext><![CDATA[Job 083418/MISJJA/XTOOLKIT started on 02/09/16 at 11:14:40 Job 083418/MISJJA/XTOOLKIT submitted.]]></jobtext>
</joblogrec>
<joblogrec>
<jobcpf>*NONE</jobcpf>
<jobtime><![CDATA[02/09/16  11:14:40.372723]]></jobtime>
<jobtext><![CDATA[CALL PGM(ZENDSVR6/XMLSERVICE) PARM('/tmp/Toolkit') QZSHRUNC main 149 PLUGILE ILECMDEXC 5497 Command ended normally with exit sta]]></jobtext>
</joblogrec>
</joblogscan>
<joblog job='XTOOLKIT' user='MISJJA' nbr='083418'>
<![CDATA[AVFDEV   02/09/16 11:14:41          Page    1
  Job name . . . . . . . . . . :   XTOOLKIT        User  . . . . . . :   MISJJA       Number . . . . . . . . . . . :   083418
  Job description  . . . . . . :   ZSVR_JOBD       Library . . . . . :   ZENDSVR6
MSGID      TYPE                    SEV  DATE      TIME             FROM PGM     LIBRARY     INST     TO PGM      LIBRARY     INST
CPF1124    Information             00   02/09/16  11:14:40.370452  QWTPIIPP     QSYS        04C0     *EXT                    *N
                                     Message . . . . :   Job 083418/MISJJA/XTOOLKIT started on 02/09/16 at 11:14:40
                                       in subsystem ZENDSVR6 in ZENDSVR6. Job entered system on 02/09/16 at
                                       11:14:40.
CPI1125    Information             00   02/09/16  11:14:40.370921  QWTPCRJA     QSYS        0110     *EXT                    *N
                                     Message . . . . :   Job 083418/MISJJA/XTOOLKIT submitted.
                                     Cause . . . . . :   Job 083418/MISJJA/XTOOLKIT submitted to job queue
                                       ZSVR_JOBQ in ZENDSVR6 from job 074594/QUSER/QSQSRVR. Job
                                       083418/MISJJA/XTOOLKIT was started using the Submit Job (SBMJOB) command
                                       with the following job attributes: JOBPTY(5) OUTPTY(5) PRTTXT()
                                       RTGDTA(QCMDB) SYSLIBL(QSYS       QSYS2      QUSRSYS    QHLPSYS    MCUTILS)
                                       CURLIB(*CRTDFT) INLLIBL(QGPL       QTEMP      NEWSYS     DBU10)
                                       INLASPGRP(*NONE) LOG(4 00 *NOLIST) LOGCLPGM(*YES) LOGOUTPUT(*JOBEND)
                                       OUTQ(/*DEV) PRTDEV(PRT01) INQMSGRPY(*RQD) HOLD(*NO) DATE(*SYSVAL)
                                       SWS(00000000)  MSGQ(QUSRSYS/MISJJA) CCSID(37) SRTSEQ(*N/*HEX) LANGID(ENU)
                                       CNTRYID(US) JOBMSGQMX(64) JOBMSGQFL(*WRAP) ALWMLTTHD(*NO) SPLFACN(*KEEP)
                                       ACGCDE(70001).
*NONE      Request                      02/09/16  11:14:40.372723  QWTSCSBJ                 *N       QCMD        QSYS        0195
                                     Message . . . . :  -CALL PGM(ZENDSVR6/XMLSERVICE) PARM('/tmp/Toolkit')
QSH0005    Completion              00   02/09/16  11:14:40.654702  QZSHRUNC     QSHELL      *STMT    XMLSERVICE  ZENDSVR6    *STMT
                                     From module . . . . . . . . :   QZSHRUNC
                                     From procedure  . . . . . . :   main
                                     Statement . . . . . . . . . :   149
                                     To module . . . . . . . . . :   PLUGILE
                                     To procedure  . . . . . . . :   ILECMDEXC
                                     Statement . . . . . . . . . :   5497
                                     Message . . . . :   Command ended normally with exit status 0.]]>
</joblog>
</diag>
</script>
Exec end: 2016-02-09 11:14:41. Seconds to execute: 0.28397703170776.
 
 
Exec start: 2016-02-09 11:14:41
Version of toolkit front end: 1.5.0
IPC: ''. Control key: *cdata *here
Stmt: call ZENDSVR6.iPLUG512K(?,?,?,?) with transport: ibm_db2
Input XML: <?xml version="1.0" encoding="ISO-8859-1" ?>
<script>
<pgm name='MSPSRVPGM' lib='' func='MSP_GETSTOREINFOPR'>
<parm comment='Type of Search'><data var='ipOremp' type='1A'>I</data></parm>
<parm comment='Search Term'><data var='searchTerm' type='15A'>172.16.10.119</data></parm>
<parm comment='Store Number'><data var='STSTR' type='3p0'>0</data></parm>
<parm comment='Store Name'><data var='STSTRN' type='15A' /></parm>
<parm comment='Clearance Store Number'><data var='STCLER' type='3p0'>0</data></parm>
<parm comment='Return Value'><data var='retVal' type='10i0'>0</data></parm>
<parm comment='Error Message'><data var='Sc_errMsg' type='60A' /></parm>
</pgm>
</script>
Output XML: <?xml version="1.0" encoding="ISO-8859-1" ?>
<script>
<pgm name='MSPSRVPGM' lib='' func='MSP_GETSTOREINFOPR'>
<parm comment='Type of Search'>
<data var='ipOremp' type='1A'><![CDATA[I]]></data>
</parm>
<parm comment='Search Term'>
<data var='searchTerm' type='15A'><![CDATA[172.16.10.119]]></data>
</parm>
<parm comment='Store Number'>
<data var='STSTR' type='3p0'><![CDATA[30]]></data>
</parm>
<parm comment='Store Name'>
<data var='STSTRN' type='15A' ><![CDATA[DRAYTON AVF]]></data>
</parm>
<parm comment='Clearance Store Number'>
<data var='STCLER' type='3p0'><![CDATA[37]]></data>
</parm>
<parm comment='Return Value'>
<data var='retVal' type='10i0'><![CDATA[0]]></data>
</parm>
<parm comment='Error Message'>
<data var='Sc_errMsg' type='60A' ><![CDATA[]]></data>
</parm>
<success><![CDATA[+++ success  MSPSRVPGM MSP_GETSTOREINFOPR]]></success>
</pgm>
</script>
Exec end: 2016-02-09 11:14:41. Seconds to execute: 0.019336938858032.
Is that expected behavior?

Post Reply