ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

webservice running in unique job

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

  • #16
    Re: webservice running in unique job

    Originally posted by Klara.Farkas View Post
    But it seems, that we shall modify this old programs leaving *LDA using out.

    Klara
    glad to hear that you can work around,
    and It is nice know this early - not yet found any document mention this limitation (is this correct word?)

    Comment


    • #17
      Re: webservice running in unique job

      Originally posted by dhanuxp View Post
      and It is nice know this early - not yet found any document mention this limitation (is this correct word?)
      I won't call it as a limitation - maybe a feature. It has benefits too, like faster running.

      Comment


      • #18
        Re: webservice running in unique job

        The reason is all repeatable business tasks are already written & well tested.
        How does that cause the *LDA to interfere with your web service?

        So far you haven't said why the *LDA needs to be different for every request. Why does it matter if every request sees the same *LDA or they all have different ones? What actually happens when two different web requests are processed and the *LDA interferes? What is the error that happens?

        We don't know anything yet about your problem, so it's difficult knowing how to help.

        Tom
        Tom

        There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

        Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

        Comment


        • #19
          Re: webservice running in unique job

          Originally posted by tomliotta View Post
          How does that cause the *LDA to interfere with your web service?

          Tom
          My webservice creates an xml about one customer's data and replies it to the client.
          This WS program calls several old programs of an old system for getting the actual data of the customer. And these old programs also call other old programs for the same purpose... And the master data of the actual customer is stored in the *LDA. So if more than one WS program is running requesting various customer's data, the master data is mixed and so the data in the reply xml is also mixed.
          This old system was written 20 years ego... and that time it was very up to date

          Comment


          • #20
            Re: webservice running in unique job

            I don't understand the problem in this thread. I agree that LDA is very out of date. (And, it was already very out of date 20 years ago, as I recall!). But why does that matter? It should still work just fine... this is what stumps me. what is the problem?

            I'm assuming that you wrote a web service similar to this (this is off the top of my head and I have not used LDA in many years, so please forgive any small syntax errors, as long as you can tell what I mean)
            Code:
            PGM PARM(&PARM1 &PARM2 &PARM3 &RESULT)           
                                                             
                DCL VAR(&PARM1)  TYPE(*CHAR) LEN(10)         
                DCL VAR(&PARM2)  TYPE(*DEC)  LEN(5 2)        
                DCL VAR(&PARM3)  TYPE(*CHAR) LEN(30)         
                DCL VAR(&RESULT) TYPE(*DEC)  LEN(5 2)        
                                                             
                /* CLEAR LDA */                              
                CHGDTAARA DTAARA(*LDA (1 2000)) VALUE(' ')   
                                                             
                /* MOVE PARAMETERS TO LDA */                 
                CHGDTAARA DTAARA(*LDA ( 1 10)) VALUE(&PARM1) 
                CHGDTAARA DTAARA(*LDA (11  5)) VALUE(&PARM2) 
                CHGDTAARA DTAARA(*LDA (16 30)) VALUE(&PARM3) 
                                                             
                /* RUN OLD PROGRAM THAT NEEDS LDA */         
                CALL PGM(OLDLOGIC)                           
                                                             
                /* RETRIEVE RESULT FROM LDA */               
                RTVDTAARA DTAARA(*LDA (46 5)) RTNVAR(&RESULT) 
                                                             
                /* CLEAR LDA */                              
                CHGDTAARA DTAARA(*LDA (1 2000)) VALUE(' ')   
            ENDPGM
            (It's probably better to write it in RPG so you can take advantage of PCML, but... you get the idea.)

            Why does it matter that it uses the LDA? The only reason I could see it mattering would be if you attempted to keep a value in the LDA that persisted between calls. That would be a problem in any web-based application because your program is stateful, and the web is a stateless environment. In which case, it has nothing to do with the LDA -- it's the simple fact that you're using a stateful approach that's the problem.

            But, that doesn't seem likely in this context... is that the problem? Or... what sort of trouble does the LDA cause?

            Comment


            • #21
              Re: webservice running in unique job

              I can understand that the *LDA gets populated by various programs that are called during the servicing of a first request. And when a second request is processed, values from the first are already in the *LDA as leftovers. That can potentially confuse programs lower in the stack.

              My first thought is to wonder what is in the *LDA at the start of the very first request. If it's blank, then it can easily be made blank for every subsequent request. Or if it has some set value, then it can have that same value set for every subsequent request. Perhaps at worst it would simply need a small wrapper.

              That should be similar to how QTEMP would be handled, but that's less certain until more is known about how it's involved.

              Tom
              Tom

              There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

              Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

              Comment


              • #22
                Re: webservice running in unique job

                Originally posted by tomliotta View Post
                I can understand that the *LDA gets populated by various programs that are called during the servicing of a first request. And when a second request is processed, values from the first are already in the *LDA as leftovers.
                Tom
                but first request is still process something & that's why we expected to have new job for each request - to have a seperate *LDA , just like how greenscreen works
                @Scott, any idea to overcome this please...
                Last edited by dhanuxp; June 28, 2013, 06:59 PM.

                Comment


                • #23
                  Re: webservice running in unique job

                  Originally posted by tomliotta View Post
                  I can understand that the *LDA gets populated by various programs that are called during the servicing of a first request. And when a second request is processed, values from the first are already in the *LDA as leftovers. That can potentially confuse programs lower in the stack.
                  Yeah, but that's been a problem with the LDA since time out of mind. LDA-based programs should always clear the LDA at the start of the procedure/process. When writing LDA-based programs, you have to be keenly aware of which programs use which parts of the LDA to make sure they don't conflict. This is one of the primary reasons why the LDA was considered a bad practice, and parameters were considered better, even way back in 1988 when the AS/400 was released.

                  Originally posted by tomliotta View Post
                  My first thought is to wonder what is in the *LDA at the start of the very first request. If it's blank, then it can easily be made blank for every subsequent request. Or if it has some set value, then it can have that same value set for every subsequent request. Perhaps at worst it would simply need a small wrapper.
                  Yep, exactly. (And is what I suggested in my sample code.)

                  Comment


                  • #24
                    Re: webservice running in unique job

                    Originally posted by dhanuxp View Post
                    but first request is still process something & that's why we expected to have new job for each request - to have a seperate *LDA , just like how greenscreen works
                    @Scott, any idea to overcome this please...
                    So you're saying that the programs for the first request are still running (they haven't yet returned control the the IWS), and a second request is made to the same job, somehow? I didn't even think that was possible... at least, not without multi-threaded programming (and I seriously doubt that IWS would do multi-threaded access... that'd make it useless to 99% of the RPG community.)

                    Can you explain this? How could it be calling the same program in the same job a second time if the first call hasn't finished?

                    Comment


                    • #25
                      Re: webservice running in unique job

                      (And is what I suggested in my sample code.)
                      Yes, I should have worded my response better and made a specific reference to your example of a wrapper.
                      Originally posted by dhanuxp View Post
                      but first request is still process something...
                      That's where it gets very confusing, as Scott said. It's not what was expected and doesn't seem reasonable. It seems almost that something else is the actual problem.

                      Does it require multiple calls to the program to finish a complete single request?

                      Tom
                      Tom

                      There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

                      Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

                      Comment


                      • #26
                        Re: webservice running in unique job

                        Originally posted by Scott Klement View Post
                        I didn't even think that was possible... at least, not without multi-threaded programming (and I seriously doubt that IWS would do multi-threaded access... that'd make it useless to 99% of the RPG community.)
                        God this is the answer... Thanks!!
                        I didn't use any load testing utiltiy and the way it behave was looks like to multi thread to me , my bad!!
                        If this is not working as multi-thread.. what Klara has to do all is just clean the LDA & QTEMP from webservice interface program
                        NO need to touch business utility !!
                        I'll defenitly try to do some testing on monday (for better understanding)

                        Thanks Tom, Thanks Scott It is privileged to talk with you guys
                        Last edited by dhanuxp; June 29, 2013, 05:41 AM.

                        Comment


                        • #27
                          Re: webservice running in unique job

                          Actually server create unique job if needed. Otherwise next request routed to the old job which is free.

                          Here what I did, I used 3 test-clients. SoapUI , i5 O/S WebService Test Client & eclipse Test Client

                          I made 2 request using SoapUI & i5 O/S client with input parameter 'ABC'
                          - it returns 2 different job number with concatenated the word ' Delay' (ABC cause to delaying the job)

                          meantime few request using 3rd client (eclipse) with something other than 'ABC'
                          - it returns same job number with concatenated what I have input


                          Originally posted by tomliotta
                          If you create something in QTEMP, you should drop it when you're finished with it. That's good practice no matter what kind of process you're running.
                          Originally posted by Scott Klement
                          LDA-based programs should always clear the LDA at the start of the procedure/process.
                          as mention above, all we have to do is cleaning the QTEMP & LDA from WS-interface program - This is enough to me, I don't have to alter the business program

                          !!

                          Thanks to the thread starter, Tom & Scott for discussion,. I've collected lot of missing fundamental knowledge. I appreciate it so much!!

                          Code:
                               H DEBUG
                               H OPTION(*SRCSTMT : *NODEBUGIO)
                               H THREAD(*SERIALIZE)
                               H BNDDIR('QC2LE')
                               H DFTACTGRP(*NO)
                               H*PGMINFO(*PCML:*MODULE)
                          
                               D SRVPGM5         PR
                               d  input                        10a
                               d  output                       20a
                          
                               D SRVPGM5         Pi
                               d  input                        10a
                               d  output                       20a
                          
                               d                SDS
                               d  JOBNUM               264    269  0
                                *
                               D LDA             DS                  DTAARA(*LDA)
                               D LDAInfo                 1     20A
                          
                                *
                               d delayJob        Pr            10i 0 ExtProc( 'sleep' )
                               d  seconds                      10u 0 Value
                                *
                                /free
                                       *Inlr = *On;
                          
                          
                                          In LDA;
                                             LDAInfo = %Char(JOBNUM) + %trim(Input);
                                             Output = LDAInfo;
                                          Out LDA;
                          
                                          If %Trim(Input) = 'ABC' ;
                          
                                             In LDA;
                                                LDAInfo = %Char(JOBNUM) + ' Delay';
                                             Out LDA;
                          
                                             DelayJob(30);
                                         
                                         EndIf;
                          
                                         In LDA;                   
                                            Output = LDAInfo;      
                                         Out LDA;                   
                          
                                       Return;
                          
                                /end-free
                          Thanks
                          Last edited by dhanuxp; July 1, 2013, 12:03 AM.

                          Comment


                          • #28
                            Re: webservice running in unique job

                            Hi Scott and all of you discussing this thread, thanks for your reply!!

                            The problem with the LDA is like this:

                            In the first running WS program I load the LDA with the key number of the custumer I want data about and call OLDLOGIC1 program.
                            That OLDLOGIC1 program calls OLDLOGIC2 program, and hopefully the key to the customer's data is still in the LDA.

                            BUT

                            If a second version of my WS program starts at the time the OLDLOGIC1 program is running in the WS1 callstack, and loads an other customer's key into the LDA, the OLDLOGIC2 program of the WS1 callstack will get the data of customer2 according to the key in the LDA. So the WS1 program will get mixed data.

                            But anyway, we already have decided to change all OLDLOGIC programs that are called by WS programs.

                            Klara

                            Comment


                            • #29
                              Re: webservice running in unique job

                              If a second version of my WS program starts at the time the OLDLOGIC1 program is running in the WS1 callstack, and loads an other customer's key into the LDA, the OLDLOGIC2 program of the WS1 callstack will get the data of customer2 according to the key in the LDA.
                              Since the second WS program should be in a different call stack or in a different job, how is it supposed to be a problem? The WS1 should be out of the call stack (making it 'different') before the second is capable of starting, though the second will more likely be in a second job and not have to wait.

                              Tom
                              Tom

                              There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

                              Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

                              Comment


                              • #30
                                Re: webservice running in unique job

                                Originally posted by tomliotta View Post
                                The WS1 should be out of the call stack (making it 'different') before the second is capable of starting, though the second will more likely be in a second job and not have to wait.

                                Tom
                                It seems, that WS1 and WS2 are working in the same job similarly and they have only one LDA and the LDA is containing always the last data.

                                Comment

                                Working...
                                X