Share this page

# Asynchronous example - poll

For a list of protocols that support asynchronous communication, see 64-bit recording, Async, and IPv6 support.

The following example describes a Vuser script that includes a poll asynchronous conversation. The application that is emulated by the Vuser is a demo of a messaging service that sends updates on demand. The browser displays the page, and sends requests for updates at intervals of approximately 5 seconds.

Copy code

    web_url("message.txt",
      "URL=http://example.com/content/message.txt?key=0",
      "Resource=0",
      "RecContentType=text/plain",
      "Snapshot=t4.inf",
      "Mode=HTML",
        LAST);

    lr_think_time(4);

    web_url("message.txt_2",
      "URL=http://example.com/content/message.txt?key=1",
      "Resource=0",
      "RecContentType=text/plain",
      "Snapshot=t5.inf",
      "Mode=HTML",
        LAST);

    lr_think_time(5);

    web_url("message.txt_3",
      "URL=http://example.com/content/message.txt?key=2",
      "Resource=0",
      "RecContentType=text/plain",
      "Snapshot=t6.inf",
      "Mode=HTML",
        LAST);

    lr_think_time(4);

    web_url("message.txt_4",
      "URL=http://example.com/content/message.txt?key=3",
      "Resource=0",
      "RecContentType=text/plain",
      "Snapshot=t7.inf",
      "Mode=HTML",
        LAST);

    lr_think_time(5);

    web_url("message.txt_5",
      "URL=http://example.com/content/message.txt?key=4",
      "Resource=0",
      "RecContentType=text/plain",
      "Snapshot=t8.inf",
      "Mode=HTML",
        LAST);

Note: You can modify VuGen's asynchronous request thresholds to assist VuGen in finding poll-type conversations. For details, see Using asynchronous request thresholds.

The above script was generated by VuGen after the required business processes were recorded. An asynchronous scan was not performed on the script after the script was generated. Notice that the script contains a series of web_url functions with a repeating URL, namely: http://example.com/content/message.txt. These web_url functions are separated by lr_think_time functions, indicating that the web_url functions repeat at intervals of approximately 5 seconds.

When the Vuser script runs, requests for http://example.com/content/message.txt should be sent repeatedly until the script is finished. Additionally, these requests should be sent in parallel (simultaneously) with other actions performed in the Vuser script.

After VuGen performed a scan for asynchronous communications on the script, the script looks as follows:

Copy code

    /* Added by Async CodcGen.
    ID=Poll_0
    ScanType = Recording

    The following URLs are considered part of this conversation:
        http://example.com/content/message.txt?key=0
        http://example.com/content/message.txt?key=1
        http://example.com/content/message.txt?key=2
        http://example.com/content/message.txt?key=3
        http://example.com/content/message.txt?key=4

    TODO - The following callbacks have been added to AsyncCallbacks.c.
    Add your code to the callback implementations as necessary.
        Poll_0 RequestCB
        Poll_0 ResponseCB */

        web_reg_async_attributes("ID=Poll_0",
        "Pattern=Poll",
        "URL=http://example.com/content/message.txt?key=0",
        "PollIntervals=4900",
        "RequestCB=Poll_0_RequestCB",
        "ResponseCB=Poll_0_ResponseCB",
        LAST);

        lr_save_int(0, "Counter_Poll_0_0");

        web_url("message.txt",
        "URL=http://example.com/content/message.txt?key=0",
        "Resource=0",
        "RecContentType=text/plain",
        "Snapshot=t4.inf",
        "Mode=HTML",
        LAST);

        /* Removed by Async CodeGen.*/
        /* Removed by Async CodeGen.*/
        /* Removed by Async CodeGen.*/
        /* Removed by Async CodeGen.*/
       /* Removed by Async CodeGen.*/

        lr_think_time(20);
        web_stop_async("ID=Poll_0",
        LAST);

Notice that a web_reg_async_attributes function has been added to the script before the first web_url function that calls http://example.com/content/message.txt, and that a web_stop_async function has been added after the last web_url function that calls the same URL.

Except for the first call to http://example.com/content/message.txt, all other web_url functions that call the same URL have been commented-out by VuGen.

Notice that the lr_think_time function has been replaced by the `PollIntervalMs` argument for web_reg_async_attributes.

The Snapshot pane for the remaining web_url function shows that the snapshots for the removed web_url functions now have Origin = Polling, and that they start at intervals of 5 seconds.

Back to top

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 26.1 All View Local Help Center View Online Help Center Version: