Introduction

Apache JMeter is a powerful open source tool designed for performance testing, attempting to load an application up by simulating some real users. Due to being very versatile and rich in features, this is a popular choice amongst developers and testers. While we know that JMeter has lots of built-in features for different kinds of transactions, the heart of JMeter lies in its Samplers. It sends a request to the server, to get a proper response. This blog post explores the functions and usage of each sampler provided by JMeter.

JMeter provided Sampler

Jmeter Sampler Types:

1. Flow Control Action

The Flow Control Action sampler in Apache JMeter is designed to manage and control the execution flow within your test plan based on specific conditions or triggers. This sampler belongs to the "Flow Control" family of elements and is particularly useful for implementing more sophisticated testing scenarios where complex flow logic needs to be handled.

2. HTTP Request Sampler

HTTP Request sampler is one of the most commonly used samplers in the JMeter. It is used to test any web server by sending different types of HTTP requests such as GET, PATCH, DELETE, HEAD, POST, PUT, or TRACE.

Features:

  • Works with any of the methods made possible by HTTP.
  • Supports parameterization and dynamic Data handling.
  • SSL/TLS support for secure communications.
  • Supports JSON, XML, and HTML Types

3. BeanShell Sampler

The BeanShell Sampler allows the execution of BeanShell scripts within the JMeter test plan. It is a Java-like scripting language that provides scripting capabilities within JMeter.

Features:

  • Allows you to run BeanShell scripts.
  • Complex script writing and logic can be used
  • It acts as an interface for interacting with JMeter variables and methods in the script.

4. FTP Request Sampler

The File Transfer domain sampler is used for performing FTP (File Transfer Protocol) operations. It provides interactions to file upload and download operations with FTP servers.

Features:

  • Supports FTP and FTPS(FTP Secure).
  • Enables upload as well download of files
  • Supports specifying file paths and handling responses.

5. JDBC Request Sampler

The JDBC (Java Database Connectivity) Request Sampler is used to interact with databases using SQL queries. It can be used with multiple database management systems (DBMS) compliant with JDBC driver and is designed for tunneling into a DB where you want to check the query performance or simply run some queries against that database.

Features:

  • SQL allows us to execute queries and retrieve results.
  • Support for Parameterized Queries (for dynamic testing)

6. Java Request Sampler

The Java Request Sampler can execute your custom Java code within the test plan. It allows the use of Java libraries and methods, giving a way to accomplish more complex logic or work with custom Java objects.

Features:

  • Allows the execution of arbitrary Java code.
  • Provides access to Java libraries and functions.
  • Allows for integration with custom Java-based components.

7. JMS Request Sampler

The JMS(Java Message Service) Request Sampler is used to interact with JMS providers by sending and receiving messages to and from JMS queues. It is a good tool for testing message-oriented middleware systems.

Features:

  • Supports various JMS providers and message types.
  • It enables message sending and receiving through JMS queues and topics.
  • Offers to configure connection settings and message formats

8. MQTT Request Sampler

The MQTT (Message Queuing Telemetry Transport) Sampler is useful only when you want to test an MQTT-based message system. It provides publish-subscribe for messages with MQTT and gives you flexibility, ideal in IoT or real-time messaging brokers.

Features:

  • Message exchange which favours MQTT protocol.
  • Allows publishing and subscribing to MQTT topics.
  • Gives you options to set up Connection settings and Message Payloads.

9. SMTP Sampler

The SMTP Sampler is used to send emails via the Simple Mail Transfer Protocol (SMTP). It allows you to set up the e-mail parameters and send emails directly in your test plan.

Features:

  • Supports SMTP for sending emails.
  • Decide what goes into the email and where it is addressed
  • Provides options for specifying SMTP server settings.

10. JNDI Request Sampler

The JNDI (Java Naming and Directory Interface) Request Sampler allows you to interact with JNDI-based services like directory/naming constraints.

Features:

  • Supports JNDI lookup operations.
  • Facilitates directory and naming services interactions.
  • Configuration options for JNDI context, and lookup.

11. SOAP/XML-RPC Sampler

This sampler is designed for testing web services that use SOAP (Simple Object Access Protocol) protocols. It is useful for testing SOAP-based web services because it can send and also receive both SOAP messages and XML-RPC.

Features:

  • Allows for the sending and receiving SOAP, XML-RPC messages.
  • Permits setting request and response handling.
  • Supports both the SOAP and XML-RPC message parameterization.

12. TCP Sampler

The TCP (Transmission Control Protocol) Sampler is designed for testing and analyzing applications that communicate over the TCP protocol. Unlike HTTP Samplers, which are used for web applications, the TCP Sampler is suitable for custom protocols and services that operate over a TCP connection.

  • Tests any application using TCP, beyond HTTP/HTTPS.
  • Allows manual specification of request data for custom commands and messages.
  • Set time limits for connection establishment and response waiting.
  • Maintains an open TCP connection for multiple requests, useful for persistent connections.

13. GraphQL HTTP Request Sampler

Using JMeter’s GraphQL HTTP Request sampler lets you simulate multiple users and test the performance of your GraphQL API. You can configure it to send GraphQL queries and mutations by setting the request body in JSON format, making it easy to test and verify specific operations.

14. Bolt Request Sampler

Here we see that JMeter uses the Bolt Request sampler to communicate with a Neo4j database using the bolt protocol. It supports load testing and performance evaluation by enabling JMeter to send queries directly to the database.

Conclusion

JMeter has a variety of samplers that can be used for testing different services and applications. It equips you to simulate load on your web servers, database messaging system, and much more using its rich performance testing capabilities. An awareness of well-suited features and usage patterns will enable you to compile effective test plans that can address all the conceivable scenarios used by your own application. Play with these samplers to exploit the power of JMeter and to make sure your applications or services are performant in all circumstances.

Thank you for reading this article. See you in the next one.