Adobe Flex/AMF: Handle polling and streaming
Note: This feature uses Adobe Flex libraries, which NeoLoad no longer supports due to security concerns. If you wish to continue using this feature at your own discretion, please reach out to Tricentis support for help getting it back.
This tutorial describes how to design a realistic Virtual User containing Adobe Flex/AMF requests based on Adobe Live Cycle Data Services
(LCDS). It shows the modeling in NeoLoad of the two standard ways of refreshing data from the Flash client, notably polling and streaming (also called Push). At the end of the tutorial, you will also find an example of advanced design, with details on how to extract and interpret data returned by a server through a streaming channel.
To gain the most from this tutorial, it is recommended to read Adobe Flex/AMF: Handle external libraries.
Understand the context
NeoLoad allows you to load test AMF requests. These requests are based on standard HTTP interactions. In most web applications, the request for data comes from the client (the web browser). In other words, it is the user who requests information either by clicking on a link or performing some other action. In some cases however, the server needs to send information to the client without the user requesting it. Typical examples of this are a server-initiated events such as alert messages and data updates.
Flex servers using the AMF protocol update client data in two ways:
-
The polling method: This involves the browser querying the server at regular intervals. Technically simple in its implementation, the method downside is that it needlessly overloads the server and it is not very reactive.
-
The streaming, or Push method: In this case, the client sends a single request to the server, and the server responds when pertinent information is available, without closing the request. Thus, the server can again send information to the client using the same connection, without having to wait for a new request. Using this method, client data can be rapidly updated while the network traffic is kept minimized.
Polling and streaming require the use of specific NeoLoad requests to be able to handle these transaction modes. For more information, see Modified User Paths.

The following example is 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 a stock price fluctuation simulation.
The steps involved in the process are:
-
Recording the scenario
-
Defining the Virtual User
-
Checking the Virtual User validity
-
Viewing a load test that includes
polling
requests
To create a Virtual User that uses AMF polling, follow these steps:
-
Record the scenario:
-
Start recording: In the NeoLoad main window, click Record button in the toolbar. Enter "UserPolling" in the Name field.
-
Access the application: The web browser opens. Enter the following URL:
http://localhost.:8400/lcds-samples/traderdesktop/index.html
-
Select nio polling mode:
-
Select the my-nio-amf-poll mode. This corresponds to an operating mode using
polling HTTP
requests through NIO sockets directly handled byLCDS
. -
By default, the operating mode selected is
my-rtmp
. This corresponds to an operating mode using theRTMP
protocol. Currently NeoLoad does not support this protocol.
-
-
Note the polling operating mode: The
my-nio-amf-poll
mode corresponds to an operating mode usingpolling
requests. The average delay between these requests is 3 seconds. This means there will be a minimum 3 second delay between two updates of the Watch List. Please wait twenty seconds or so (in other words, 7 refresh cycles). -
Stop recording:
-
Close the browser, then click Stop. The Post-Recording Wizard displays the Push Application window.
-
NeoLoad has detected that the recorded Virtual User has used Push
AMF polling
. Click Finish. -
The Post-Recording Wizard creates the
UserPolling_AMF
Virtual User from the recorded Virtual User.
-
-
Check the recording:
-
The
UserPolling
user contains the raw recording of the requests. -
Select the
UserPolling_AMF
Virtual User, right-click, then select Show all. The polling request appears in thepolling_loop
loop under thepush_fork
fork. -
The Push messages are located in the
POLL_3
polling request. Theflex.samples.marketdata.Stock
message is a Push message executed each time a response message contains aflex.samples.marketdata.Stock
-type object.
-
-
-
Define the Virtual User:
-
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
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_1
located in theflex.samples.marketdata.Stock
Push message and enter the following JavaScript code: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
andDefaultMessage
Push messages.
-
-
Validate the Virtual User:
-
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: Click the Start checking button in the validation window.
-
Check the server responses:
Several
polling
requests and Push messages have been executed. Click on any one of them to check its contents. With a Push message selected, click Response.The speed of execution in the validation check playback is real; this avoids submitting the server to too high a
polling
rate. In testing, 3 seconds minimum separate eachpolling
request.NeoLoad allows you to work on an XML representation of the objects passing through the server. In this example, you can see the XML representation of an instance of the example class
flex.samples.marketdata.Stock
returned by the server.Copy<body class="ASObject" mappedClass="flex.samples.marketdata.Stock">
<open tagClass="double">33.61</open>
<last tagClass="double">32.41972272641574</last>
<symbol tagClass="String">GE</symbol>
<name tagClass="String">General Electric Company</name>
...
</body>Here is an extract of the associated Java class:
Copypackage flex.samples.marketdata;
import java.util.Date;
public class Stock {
protected double open;
protected double last;
protected String symbol;
protected String name;
...
public double getOpen() {
return open;
}
public void setOpen(double open) {
this.open = open;
}
public double getLast() {
return last;
}
public void setLast(double last) {
this.last = last;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
-
-
View a load test that includes polling requests:
-
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
polling
. -
Start the test: Click the Play button in the toolbar. Then click OK. The test starts. Wait 2 minutes.
-
Results: The test results allow you to check the server performance for each Push message.
-

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:
-
Recording the scenario
-
Defining the User Path
-
Validating the User Path
-
Viewing a load test that includes a
streaming
request. -
To learn more, see how to set the User Path advanced definition hereinafter.
To define a User Path using streaming-type AMF requests, follow these steps:
-
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 tomy-nio-amf-stream
in the list to apply the operating mode for streaming requests. This corresponds to an operating mode with streaming requests throughNIO
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 thestreaming
. Close the browser, then clickon
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.
-
-
-
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 enterlogger.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
andDefaultMessage
Push messages.
-
-
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.
-
-
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 forpolling
and, therefore, a reduced capacity in handling simultaneous users.
-
-
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 theGeneral Electric
stock is above31
. -
User Path actions when GE_last > 31:
-
In the
"Then"
condition, drag and drop theJavaScript
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 theUNSUBSCRIBE
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 theUNSUBSCRIBE
page). In the previous example, the GE stock has reached 34, triggering the JavaScript and ending the Virtual User.
-