In this case the better option to connect to these network of brokers instead of using a fail over with all the ip's of the brokers or connecting individual brokers would be to use the discovery URL so to let the fabric manage the details.
Based on the below post from
https://github.com/FuseByExample/external-mq-fabric-client
There are three ways this can be done from Jmeter.Adding the System properties zookeeper.url and zookeeper.password while starting the Jmeter.
Editing the Jmeter.sh and adding the JVM Parameters
- Edit jmeter.sh.
- Append the below parameter to the JMETER_OPTS"-Dzookeeper.url=<zookeeperurl> -Dzookeeper.password=<zookeeperpassword>".
- Add the below jars to the lib/ext directory.
- activemq-all-5.11.1.jar
- fabric-api-1.2.0.redhat-133.jar
- fabric-groups-1.2.0.redhat-133.jar
- fabric-utils-1.2.0.redhat-133.jar
- fabric-zookeeper-1.2.0.redhat-133.jar
- guava-17.0.jar
- jackson-annotations-2.4.3.jar
- jackson-core-2.4.3.jar
- jackson-databind-2.4.3.jar
- mq-discovery-1.2.0.redhat-133.jar
- mq-fabric-1.2.0.redhat-133.jar
- Run the script jmeter.sh and continue with the JMS publisher and JMS subsriber tests
- The sample parameters are as below
- intialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory.
- providerUrl=discovery:(fabric:<broker-group-name>).
- connection factory =ConnectionFactory.
- Destination = dynamicQueues/FOO.BAR.
Customizing the JMSPublisher Sampler with GuiControls
- Copy the same jars from above step to lib/ext directory of Jmeter installation.
- Write custom code to add a new sampler JMS Activemq Discovery Publisher.I went along the lines of JMSPublisherGui and PublisherSampler from the JMS protocol code , most of the code is copied from them with necessary modifications.
- Create a class DiscoveryActivemqPublisherGui that extends AbstractSamplerGui and implements ChangeListener
- Create a class DiscoveryPublisherSampler which extends
BaseJMSSampler and implements TestStateListener
to write the actual Sampler code. - In the initClient method of DiscoveryPublisherSampler write code to set the zookeeper properties to the system variables.
- Copy the core part of the source code of Jmeter from here.
- Add the property jms_discovery_publisher= JMS Activemq Discovery Publisher to messages.properties. This will be the label of the Sampler.
- Use the pom.xml below to compile the code.
For the complete code please click here
No comments:
Post a Comment