ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

webservice running in unique job

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

  • #31
    Re: webservice running in unique job

    Originally posted by Klara.Farkas View Post
    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.
    From my testing & understanding, WS1 & WS2 don't work simultaneously in the same job..
    If one program is running, IWS creates NEW job and routed your second program/request to it.
    If not, it will use OLD Job which containing OLD LDA data - that's why we need cleaning process
    Last edited by dhanuxp; July 1, 2013, 10:51 PM.

    Comment


    • #32
      Re: webservice running in unique job

      Originally posted by dhanuxp View Post
      If not, it will use OLD Job which containing OLD LDA data - that's why we need cleaning process
      That is indeed the way to think of it.

      The *LDA always needs to be initialized regardless of whether it's used in an interactive job, a batch job, a server job or any job. If a program is called in the job that uses data from the *LDA, then something earlier in the job must prepare the *LDA.

      If a web server job calls PGMA and PGMA calls PGMB, when PGMB puts data into the *LDA, that will still be there when the stack returns to PGMA and when it returns to any web server program. If the same web server job calls PGMA again, the *LDA will be unchanged from its previous value.

      That's the same way it happens in an interactive job if you call the same PGMA from a system command line. If you call PGMA two times in the same job, the *LDA data will still be there the second time unless you do something to change it between the calls.

      But if you make the second call from a different interactive job, the *LDA from the first job will not be there.

      The difference is that you would make a human choice to call from the same or different interactive job. But with web server jobs, you can't predict when it will be the same or different web server job.

      That means that you have to assume that it will always be the same job and that you have to do something to clean up the *LDA. You could modify PGMA to clear the *LDA as soon as it is called every time, or you could create a new program, PGMw. Then have PGMw clear the *LDA before it calls PGMA, and have the web service call PGMw instead of PGMA.

      It can be a very simple "wrapper" program that allows you to call PGMA without needing to change it.

      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


      • #33
        Re: webservice running in unique job

        Originally posted by Klara.Farkas View Post
        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.
        I don't think that's true (as others have said) unless you've enabled some feature that I'm not familiar with? The only way it'd re-use the same job is if the prior web service call has already completed. Otherwise, it'd start a second job to run the 2nd web service call in. So this should not be a problem.

        The only problem is that if the first call DID complete normally, the second call might have remnants of the first call still left over in the LDA. That's why my sample code in this thread was careful to clear the LDA, so it wouldn't accidentally use data left over from the previous call.

        Now if you want to use data left over from a previous call, that's a different sort of problem. In that case, you are trying to make your program stateful, which is a new set of challenges, because web technology was designed to be stateless. Since the next call could end up in a different job, you can't just leave details behind in the LDA. But, you can issue a session number in the response from the first program. Subsequent programs can receive that session number back, and look data up in a session database. But, if at all possible, it's better NOT to try to keep data across multiple calls.... in other words, it's better to be stateless.

        Originally posted by Klara.Farkas View Post
        But anyway, we already have decided to change all OLDLOGIC programs that are called by WS programs.
        It's always good to modernize your code when you have to make changes, anyway. And changing from LDA to parameters is not usually a very difficult thing. So it is probably very good that you are doing this.

        However, I hate to see this happen based on a misunderstanding.

        Comment


        • #34
          Re: webservice running in unique job

          Thank you very much everybody for the replies!
          It is satisfying, what you have written!

          Comment

          Working...
          X