In this post I will tackle a task of sending a simple text JMS message to a Oracle AQ queue using JMeter. Next week, I will follow that with a description of what to do to send a JMS byte message in JSON format. Stay tuned for that one.

There are two samplers in JMeter which can do a job of sending a message to a queue: JMS Point-to-Point and JMS Publisher. The decision of  which one to use might depend on your use case and which JMS messaging model is used by your project.

Below I will show you how to utilize the JMS Point-to-Point sampler. I’m not forgetting the other sampler though, JMS Publisher will make an appearance in the next post.

 

Initial Configuration

 

Before we can start playing with the queues in JMeter we need to provide some additional libraries. You will need to put them into JMeter’s /lib/ folder. Note, depending on the queuing mechanism, different libraries need to be used, the list below pertains only to Oracle AQ.

 

Required libraries:

 

  • ojdbc.jar (version of the ojdbc library depends on the Oracle DB version you use e.g. Ojdbc7 can be used for Oracle 11g, Ojdbc8 for Oracle 12c etc. )
  • aqapi.jar
  • jta.jar
  • jndi.properties.jar, that you will need to create by yourself:
1. Just put one line into a file that might be called jndi.properties specifying your thin connection to the database:
db_url=jdbc:oracle:thin:@${dbHost}:${dbPort}:${dbSID}
2. Package it into a jar by executing the line below:
jar cf jndi-properties.jar jndi.properties

 

Now we can continue with setting up the sampler.

 

How to configure the JMS Point-to-Point sampler

JMS point-to-point sampler configuration

 

Just substitute the variables you can observe in the screenshot with following values:

  • connectionFactory = QueueConnectionFactory
  • initialContextFactory = oracle.jms.AQjmsInitialContextFactory
  • destinationQueueName = your destination queue
  • queueUsername = your username
  • queuePassword = your password
  • jdbc:oracle:thin:@${queueHost}:${queuePort}:${queueSID} = connection string to your Oracle database

 

And we are done! It is as simple as that.

 

Different ways of providing message

Of course you don’t need to hard-code the message completely in the sampler’s “Content” field like above, but can parameterize it or read it from a file.

  • parameterization of the message:

jms message parameterization

  • to read a message from a file you can use JMeter’s StringFromFile function:
${__StringFromFile(c:\path_to_file.txt)}

 

  • to read a message containing some variables and substitute it with values in the runtime use eval function:
${__eval(${__StringFromFile(c:\path_to_file.txt)})}