+

Search Tips   |   Advanced Search


Define a User Path using streaming-type AMF requests

The same previous example is used, namely one provided by Adobe and included in LCDS (http://www.adobe.com/products/livecycle/dataservices/). Follow the installation instructions and then start the LCDS server. Then, go to the following URL: http://localhost:8400/lcds-samples/traderdesktop/startfeed.jsp. This page activates the stock price fluctuation simulation.

The steps involved in creating a User Path that uses AMF streaming are:

  1. Recording the scenario
  2. Defining the User Path
  3. Validating the User Path
  4. Viewing a load test that includes a streaming request.
  5. To learn more, see how to set the User Path advanced definition hereinafter.

  1. Record the scenario:

    • Start recording: In the NeoLoad main window, click the Record button in the toolbar. Enter "UserStreaming" in the Name field and click OK.
    • Access the application: The web browser opens. Enter the following URL: http://localhost.:8400/lcds-samples/traderdesktop/index.html
    • Change the operating mode to streaming:

      • The my-rtmp operating mode is selected by default. Change the mode to my-nio-amf-stream in the list to apply the operating mode for streaming requests. This corresponds to an operating mode with streaming requests through NIO sockets . NIO sockets are used to break the relationship between the number of streaming channels opened and the number of used threads on the server side.
      • In streaming mode, the server refreshes the displayed data when it decides it is necessary. You can see the difference in refreshment rate compared with polling mode. Please wait ten seconds or so.
    • Stop the recording: Change back to the my-rtmp mode in order to shut down the streaming. Close the browser, then click on Finish.
    • Check the recording:

      • Click on the UserStreaming_AMF user, then right-click and select Show all. There are 2 streaming requests (identified by the red document icon) named /nioamfstream;AMFSessionId=XXX open and /nioamfstream close, one to open streaming and one to close it.
      • Click on the UNSUBSCRIBE page and set the think time for the page to 10000ms. In an advanced scenario, you could make the think time dynamic using a random variable, setting a maximum and minimum think time.
    • Check the streaming open request:

      • Unlike polling mode, just one request is sent to the server in this mode. The server sends data back in a response when it decides it is appropriate, until it closes the connection when streaming is finished. These different response data groups are stored by NeoLoad as several responses.
      • Select the /nioamfstream;AMFSessionId=XXX open request. Click on the Advanced button. In the dialog box, select the Recorded response tab. Finally, in the left-hand panel, select one of the responses. NeoLoad displays a list of all the responses sent by the server during the streaming request recording.
  2. Define the User Path:

    • Extract and display the received stock symbol:

      First, you need to set a variable extractor on the Push message to extract the symbol:

      • Select the flex.samples.marketdata.Stock_1 Push message, then click Advanced.
      • Create a variable extractor.
      • Enter "Symbol" in the Variable name field.
      • Check the XPath Expression box and enter "//symbol" in the corresponding field.
      • Enter ">" in the Starts with field.
      • Enter "<" in the Ends with field.
      • Click OK to create the variable extractor.

      Create a JavaScript action in messageFork_2. Delete the existing JavaScript code and enter logger.debug("STOCK = "+ context.variableManager.getValue("symbol"));

      The JavaScript action will display the stock symbol extracted from the message.

    • Keep the appropriate Push messages: This Virtual User is only interested in the stock symbols received. Delete the flex.messaging.messages.AcknowledgeMessageExt, String and DefaultMessage Push messages.
  3. Check the Virtual User validity:

    • Go to the Virtual User Validation section: In the NeoLoad main window, click the green tick button in the toolbar.
    • Configure the think time playback: Click on the Advanced button in the validation window. Check the Play think time box, then click OK.
    • Start the Virtual User validity check: Select "UserStreaming" in the Virtual Users list. Then click on the Start checking button in the validation window.
    • Check the server responses: The same streaming request appears several times. Only one request was issued for this Virtual User, but the server regularly sends back partial responses. When each partial response is received, a line is added to the list of played requests, together with its content. Click on one to check the contents. When the request is selected, click on Response.
  4. View a load test that includes a streaming request:

    • Go to the Population Definition section: In the NeoLoad main window, click Populations.
    • Define the default Population: In the Population Creation Wizard, click OK.
    • Go to the Load Policy section: Click Runtime.
    • Define the load policy: Enter "10" in the Simulated users field. NeoLoad will launch 10 Virtual Users using streaming.
    • Start the test: Click on the Play button in the toolbar. Then click OK. The test starts. Wait 2 minutes.
    • Results: As the test proceeds, NeoLoad clearly shows the speed of this architecture, with a considerable number of responses being received by each Virtual User. Streaming also provides very fast response times. However, its use implies greater server-side resources than are required for polling and, therefore, a reduced capacity in handling simultaneous users.
  5. Set the Virtual User advanced definition:

    You will continue with the previous example, this time focusing on the content of the response to the streaming request. You will see how NeoLoad extracts part of the content sent by the server and help you make decisions. Here is the proposed scenario: when the value of the General Electric (symbol GE) stock rises above 31, a log is displayed and the Virtual User stops.

    • Go to the User Paths: In the NeoLoad main window, click Virtual Users.
    • Edit the Push message conditions:

      • Select the "flex.samples.marketdata.Stock_1" Push message in the tree. In the Settings section, select Conditions, then Resolve all the following elements.
      • Click + (plus) to set the new condition "${NL-MessageContent}" "contains""<String>GE</String>".
      • The Push message is now configured to execute only when an update for the "GE" stock is received.
    • Extract the received stock value:

      • Select the "flex.samples.marketdata.Stock_1" Push message, then click Advanced. Create a variable extractor:
      • Enter "GE_last" in the Variable name field.
      • Check the XPath Expression box and enter "//last" in the corresponding field.
      • Enter ">" in the Starts with field.
      • Enter "." in the Ends with field.
    • Check the variable extractor validity:

      • Lastly, check the extraction results. The Value extracted from the recorded page field at the bottom of the variable extractor definition window must contain a number.
      • Click OK to confirm, then click OK again.
    • Define a condition block for GE_last > 31: Drag and drop the If...Then...Else logical action under /nioamfstream;AMFSessionId=XXX open page. Double-click on the Operand1 field, then click on the picker buttion and select "GE_last". Click OK. In the Operator field, select "is greater than". In the Operand2 field, enter "31". This condition block will only be true when the quote for the General Electric stock is above 31.
    • User Path actions when GE_last > 31:

      • In the "Then" condition, drag and drop the JavaScript logical action. Erase the default code and replace it with:
      • context.variableManager.setValue("end","true");
      • Drag and drop the "Wait until" logical action just before the UNSUBSCRIBE page. Set the maximum delay to 60000ms and set the action "${end}" "is equal to" "true" condition to "wait until".
      • Delete the "end_delay_3" action.
      • Set the think time for the "UNSUBSCRIBE..." and "/nioamfstream close_1" pages to 0ms.
    • Check the User Path validity: Click on the green tick button in the NeoLoad toolbar. Select "UserStreaming" in the Virtual Users list. Next, click on the Start checking button in the validation window. The validation process is run until the GE stock reaches 31, or until the "wait until" action times out (think time for the UNSUBSCRIBE page). In the previous example, the GE stock has reached 34, triggering the JavaScript and ending the Virtual User.


Home