Introduction


In case you want to simulate complex behavior of real users, you may need to run more than one threading pattern. For example, imagine you have bank accountants who do some work in the morning, then have a lunch break and do some other work after lunch. This is easy to achieve by running more than one action queue one after another(one for the morning and one for the afternoon accountants' work).

But when you look at the Test Explorer statistics you may want to see all the user activity in the same table. This is very easy to achieve and this page explains shows it.



Two separate action queues

        // Create the morning loader
        LoadClient morningLoader = new LoadClient( LOADER_ADDRESS );
        morningLoader.setThreadingPattern( new AllAtOncePattern( 10, true, 3, 2000 ) );

        // run the morning actions
        morningLoader.startQueueing( "Morning bank operations" );
        BankActions morningBankActions = new BankActions();
        morningBankActions.payCache( );
        morningLoader.executeQueuedActions();

        // Give them 30 minutes for lunch :)
        Thread.sleep( 30 * 60 * 1000 );

        // Create the afternoon loader
        LoadClient afternoonLoader = new LoadClient( LOADER_ADDRESS );
        afternoonLoader.setThreadingPattern( new AllAtOncePattern( 10, true, 3, 2000 ) );

        // run the afternoon actions
        afternoonLoader.startQueueing( "Afternoon bank operations" );
        BankActions afternoonBankActions = new BankActions();
        afternoonBankActions.payCache( );
        afternoonBankActions.payWithCard( );
        afternoonLoader.executeQueuedActions();

The result

As you can see we have "Morning bank operations" queue, half-hour no work and then "Afternoon bank operations" queue. Of course, your queue should last for a few hours, not like ours here.

Both queues can contain the same or different actions from the same or different action classes.

In our example, both queues run actions from the same action class(the imaginary BankActions). There is an action(called payCache) ran by both queues, but there is also an action ran by just one of the queues(called payWithCard).



Combined action queues

Now change the code by naming both queues with the same name, for example, "Complex bank operations" and run it again.

The result


The execution is the same in terms of threading patterns and actions, but both report tables are merged into a single one. Of course, now it is not easy to understand which actions were run in the morning and which afternoon.

You can combine many patterns and these patterns can vary in type, number of users, actions etc.



Back to parent page

Go to Table of Contents