Announcement

Collapse
No announcement yet.

MvASYNCHRONOUS -- Does anyone have an example

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

    MvASYNCHRONOUS -- Does anyone have an example

    If you have an example or recommendations on its usage, please share. I assume the Scheduled Task feature in Miva uses it in ScheduledTasks_Spawn_AsynchronousTask() in the LSK but alas this function is not included.

    A scheduled task module is not that difficult to write, but that would be overkill for my situation.
    Ray Yates
    "If I have seen further, it is by standing on the shoulders of giants."
    --- Sir Isaac Newton

    #2
    Code:
    <MVASYNC>
        <MvIF EXPR = "{ NOT [ g.Module_Library_Utilities ].Initialize_Async_Environment( 'scheduled', 'STORE_CODE_HERE' ) }">
            <MvFUNCTIONRETURN>
        </MvIF>
    
        ...
    </MvASYNC>
    David Carver
    Miva, Inc. | Software Developer

    Comment


      #3
      David, Thanks for the snippet. What is the use case? Or, what issue would this potentially solve or help?

      Scott
      What help do you need today!
      Interactive Design Solutions http://www.southbound.com
      MivaMerchant Business Partner | Certified MivaMerchant Web Developer
      My T-shirt Collection is mostly MivaCon T-shirts!!
      Competitive Rates, Popular Modules, and Integrations:
      Product Copy | AutoBaskets | Waitlist Integration| Wholesale Integration

      Comment


        #4
        Originally posted by RayYates View Post
        A scheduled task module is not that difficult to write, but that would be overkill for my situation.
        Having it in that location can have other benefit though. We or a store operator may have reason to want to temporarily disable scheduled tasks, and turning them off is quite easy in the Scheduled Tasks location, vs a module firing its own and possibly creating an unexpected event. Scheduled Tasks also have useful logging.
        David Hubbard
        CIO
        Miva
        [email protected]
        http://www.miva.com

        Comment


          #5
          I use mvasync for anything that might time out since the async process is, from what I've been told, a roughly 60 minute process done in the background. If I need to show progress I create a flat file that has whatever progress data I want and check for it if the user triggers a progress display. Important to know that mvasync won't work with store functions or anything like that unless you initialize the store environment, similar to how you'd need to init the store environment for mvprocessupload.
          M.A.D.* since 1997

          http://www.scotsscripts.com

          *miva application developers

          Comment


            #6
            Here is one of our examples. We have started to use this wherever possible LOVE IT!
            This code adds an email to our mailing list company upon a new sign up to our service (orangemailer.co)

            <MvASYNCHRONOUS>
            <MvASSIGN NAME="l.crlf" VALUE="{ asciichar(13) $ asciichar(10) }">
            <MvAssign name="grant_type" value="client_credentials">
            ...
            <MvCAPTURE VARIABLE = "l.json">
            <MvEval expr="{ '{
            "emails":[
            {
            "email":"' $ email $ '",
            "variables":{
            "First_Name":"' $ firstname $ '",
            "Last_Name":"' $ lastname $ '",
            "name": "' $ fullname $ '"
            }
            }]
            }' }">
            </MvCapture>
            <MvCall action="{ 'https://api.sendpulse.com/addressbooks/71832/emails' }" method="RAW" HEADERS="{ 'Authorization: Bearer ' $ l.theToken $ l.crlf }" CONTENT-TYPE="application/json" FIELDS="l.json" FLAGS="noparse">
            </MvCall>
            </MvASYNCHRONOUS>
            William Gilligan - Orange Marmalade, Inc.
            www.OrangeMarmaladeinc.com

            Comment


              #7
              Hey Bill,

              What issue does it solve or make easier?

              Scott
              What help do you need today!
              Interactive Design Solutions http://www.southbound.com
              MivaMerchant Business Partner | Certified MivaMerchant Web Developer
              My T-shirt Collection is mostly MivaCon T-shirts!!
              Competitive Rates, Popular Modules, and Integrations:
              Product Copy | AutoBaskets | Waitlist Integration| Wholesale Integration

              Comment


                #8
                Hey Scott,
                In this case - we pass the new user directly to our outsourced mailing list - with no waiting on the mvcall response.
                We don't care if there is an error - cause nothing is dependent on the email getting entered.
                And since we don't have to wait for the callvalue - we just keep going. Saves some amount of time.
                William Gilligan - Orange Marmalade, Inc.
                www.OrangeMarmaladeinc.com

                Comment

                Working...
                X