Thursday, January 7, 2016

When fabric is used to create network brokers fabric assigns free ports so that they will not all run on default port settings , also this provides the flexibility to the users to add more brokers in to the mix later on or remove them when the load becomes lesser.

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
  1. Edit jmeter.sh.
  2. Append the below parameter to the JMETER_OPTS
    "-Dzookeeper.url=<zookeeperurl>  -Dzookeeper.password=<zookeeperpassword>".
  3. Add the below jars to the lib/ext directory.
    1. activemq-all-5.11.1.jar
    2. fabric-api-1.2.0.redhat-133.jar
    3. fabric-groups-1.2.0.redhat-133.jar
    4. fabric-utils-1.2.0.redhat-133.jar
    5. fabric-zookeeper-1.2.0.redhat-133.jar
    6. guava-17.0.jar
    7. jackson-annotations-2.4.3.jar
    8. jackson-core-2.4.3.jar
    9. jackson-databind-2.4.3.jar
    10. mq-discovery-1.2.0.redhat-133.jar
    11. mq-fabric-1.2.0.redhat-133.jar
  4. Run the script jmeter.sh and continue with the JMS publisher and JMS subsriber tests
  5. The sample parameters are as below
    1. intialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory.
    2. providerUrl=discovery:(fabric:<broker-group-name>).
    3. connection factory =ConnectionFactory.
    4. Destination = dynamicQueues/FOO.BAR.
Customizing the JMSPublisher Sampler with GuiControls
  1. Copy the same jars from above step to lib/ext directory of Jmeter installation.
  2. 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.
  3. Create a class DiscoveryActivemqPublisherGui that extends AbstractSamplerGui and implements ChangeListener
  4. Create a class DiscoveryPublisherSampler  which extends
    BaseJMSSampler  and implements TestStateListener
    to write the actual Sampler code.
  5. In the initClient method of DiscoveryPublisherSampler write code to set the zookeeper properties to the system variables.
  6. Copy the core part of the source code of Jmeter from here.
  7. Add the property jms_discovery_publisher= JMS Activemq Discovery Publisher to messages.properties. This will be the label of the Sampler.
  8. Use the pom.xml below to compile the code.
  • Replace the ApacheJMeter_core.jar with the jar obtained above.
  • For the complete code please click here

    No comments:

    Post a Comment