• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Best practice to handle COMMITMENT control

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best practice to handle COMMITMENT control

    Hi,

    I want my program to handle the files with commitment control and journaling,
    in a normal 'green screen' application i normally start the commitment ctl in a cl-program after which the RPG is launched, and after that back in the CL, the ENDCMTCTL.

    how is this best handled in a Valence program- where the same VVCALL handles the 'traffic' - and as for as i know, leaves a program and files open for performance reasons?..

    i was thinking of putting my files in USROPN and launching the commitment ctl before opening the files, and directly after commit doing ENDCMTCTL... but i think this will have an effect on performance...

    can you please advice on what the best practice is


    thx

    Thierry

  • #2
    Hi Theirry,

    I would definitely not recommend starting & stopping commitment control on each call. I would suggest you simply start commitment control at the job-level once on each job, then leave it running until the job ends (i.e., when the instance is terminated or restarted, commitment control would end automatically). Of course, you must be careful to commit or rollback everything in your RPG programs before they end, but that would definitely be a best practice in itself.

    I believe if you're using SQLRPGLE then commitment control is started automatically at the activation group level (superseded within the RPG program via EXEC SQL SET OPTION COMMIT=*NONE). But you have to manually start commitment control on straight RPGLE programs. And for CGI jobs with a mix of RPGLE and SQLRPGLE programs being called I think it makes more sense to have commitment control running at the job level, so it doesn't matter what named activation group(s) you're using.

    So I would suggest you use the VVCALL exit program logic and create a simple program that guarantees job-level commitment control is running within each CGI job. Something like this should work:
    Code:
     /copy qcpylesrc,vvHspec                                            
    ** --------------------------------------------------------------   
    **     Object ID: CHECK_CC                                          
    **       Version: V4.0                                              
    **   Description: Check that commitment control is started         
    **                on current CGI job                                
    ** --------------------------------------------------------------   
    **--------------------------------------------                      
    **  d specs                                                         
    **--------------------------------------------                      
    d exitDS        e ds                  extname(vvDSexit1)            
    d sessionDS     e ds                  extname(vvsessdata) qualified 
    d IOexitDS        s                   like(exitDS)                  
    d*                                                                  
    d Cctl           uds                  dtaara(*lda) qualified        
    d  running                       1a                                 
    d*                                                                  
    d Qcmd            pr                  extpgm('QCMDEXC')             
    d  cmd                         500a   options(*varsize)const        
    d  cmdLen                       15  5 const                         
     /copy qcpylesrc,vvDspec                                            
                                                                        
    **--------------------------------------------                      
    **  program start                                                                            
    **--------------------------------------------                                               
    C     *entry        plist                                                                    
    C                   parm                    IOexitDS                                         
     /free                                                                                       
                                                                                                 
      exitDS=IOexitDS;                                                                           
                                                                                                 
      if vvExitMode='VVCALL0';                                                                   
        // ensure commitment control is started prior to calling any RPG program                    
        // associated with an app from VVCALL...                                                    
        in Cctl;                                                                                 
        if Cctl.running<>'1';                                                                    
                                                                                                 
          // end activation group-level commitment control if already started...                 
          callp(e) qcmd('ENDCMTCTL':10);                                                         
                                                                                                 
          // start job-level commitment control, leave it that way until job ends...             
          callp(e) qcmd('STRCMTCTL LCKLVL(*CHG) CMTSCOPE(*JOB)':100);                            
                                                                                                 
          // update the LDA to signal future calls that commitment control is already started... 
          CCtl.running='1';                                                                      
          out CCtl;                                                                              
                         
        endif;           
      endif;             
                         
      *inlr=*on;
    Compile this program then specify its name in Portal Admin > Settings > Exit programs > "Within VVCALL, pre-processing" setting.

    Of course, this is all theoretical, I haven't tried it myself. But it should work as long as you don't have any programs out there ending commitment control (ENDCMTCTL) for some reason.

    I'll be curious to hear how this works for you. If it does the trick we might consider incorporating something like this into VVCALL itself in Valence 4.1. So please keep us posted!

    -Rob

    Comment

    Working...
    X