// Connect using the test parameters.
connection = TestUtils.createConnection(testProps);
// Create a circuit end that matches the assigned role and test parameters.
LocalCircuitFactory circuitFactory = new LocalCircuitFactory();
switch (role)
{
// Check if the sender role is being assigned, and set up a message producer if so.
case SENDER:
// Set up the publisher.
circuitEnd = circuitFactory.createPublisherCircuitEnd(connection, testProps, 0L);
// Create a custom message monitor that will be updated on every message sent.
messageMonitor = new MessageMonitor();
break;
// Otherwise the receivers role is being assigned, so set this up to listen for messages.
case RECEIVER:
// Set up the receiver.
circuitEnd = circuitFactory.createReceiverCircuitEnd(connection, testProps, 0L);
// Use the message monitor from the consumer for stats.
messageMonitor = getMessageMonitor();
break;