engineer diaries Logo

JMeter Sampler And its types with Examples | EngineerDiaries

Jan 28, 2021, 1149 Views, 0

Contents

  • FTP Request
  • HTTP Request
  • JDBC Request
  • Java object request
  • JMS request
  • JUnit Test request
  • LDAP Request
  • Mail Request
  • OS Process Request
  • TCP Request
  • Jmeter Sampler is a component attached to the thread group which sends in the request to the server. Thread groups use the concept of multithreading where we decide the number of users to test the load. The sampler at times is put under logical controller to tell how many times the request needs to be sent in. Now to store the result of the sampler to the disk we attach a listener where the response is recorded in the graph format or tree format.  To even customize the request we could add configuration elements like cookie manager etc. Now, Jmeter allows to send multiple types of requests or one could say almost all the possible requests which are listed below and we will talk about each henceforth. 

    1.FTP Request
    2.HTTP Request (can be used for SOAP or REST Webservice also)
    3.JDBC Request
    4.Java object request
    5.JMS request
    6.JUnit Test request
    7.LDAP Request
    8.Mail request
    9.OS Process request
    10.TCP request

    1.FTP Request

    FTP Requests is a protocol for transferring files between the systems. But in recent times, the file-sharing is not that much done via FTP, and rest API and HTTP are most commonly used. Here also we would be uploading files via the FTP Sampler to an FTP server like Filezilla for instance. There is also a provision to hit the FTP server and get a file as a response. Cool right?



    JMeter Sampler And its types with Examples | EngineerDiaries

    2.HTTP Request

    HTTP Request Sampler is used to send in both the HTTP and HTTPS requests to the server. HTTP is a hypertext transfer protocol at the application layer whereas Hyper Text Transfer Protocol Secure is for secure communication using the transport layer.  The sampler allows you to attach images, files too in the request body along. And in the advanced section, you can even retrieve those files and download them to the disk.


    JMeter Sampler And its types with Examples | EngineerDiaries

    3.JDBC Request

    JDBC sampler lets you send queries to the database. The database could be Oracle, SQL Server, MySQL, etc.  You could provide in variables parameter to store in the result retrieve or could basically attach a listener along with it. To connect to a database you need a connection string that is passed in the database URL and JDBC Driver class. Now, these configurations are not available in the JDBC sampler but need to be added through the configuration element. One could add a username and password for DB access or in connection string also.


    JMeter Sampler And its types with Examples | EngineerDiaries

    4. JAVA Object Request

    Java object Request is one of the best parts of the sampler. Suppose you have created a method in JAVA in your eclipse IDE. Now to load test, you can implement the Jmeter interface org.apache.jmeter.protocol.java.sampler.JavaSamplerClient, pass in the parameters required by the method you can create in eclipse and then use it for multiple users and datasets. By default, there are two methods provided one for a sleep test, other for java test. 



    JMeter Sampler And its types with Examples | EngineerDiaries

    5.JMS Request

    JMS is Jakarta Messaging API which is an interface for messaging. JMS is an java based messaging middleware to help sending messages between consumers and senders. To load test the API also, Jmeter sampler has this provision. Where you add the server address with authentication requirement to test the response as if the messages are being delivered, or there is some time lag or exception been raised by the server in case of heavy traffic.


    JMeter Sampler And its types with Examples | EngineerDiaries

    6.JUnit Request

    Junit is used as a unit testing framework for Java. Here Jmeter creates one instance per sampler and reuses it to change it, the checkbox of 'create a new instance per sample' must be selected. JUnit Sampler scans the jar files and the classes extending JUnit test cases. Also, the jar files are placed in jmeter/lib/junit folder. Details in the screenshot down below where you can not call for the property of tearDown and setUp also. 


    JMeter Sampler And its types with Examples | EngineerDiaries

    7.LDAP Request

    Lightweight Directory Access Protocol is used for authentication via directory services. @gmail, @yahoo, @hotmail, @microsoft are all individual directories.  LDAP sampler allows to add, edit, delete and search to an LDAP server. You need to provide the domain name, a port which is usually 389, and base Domain name to get the result from the LDAP server. Every organization has there own active directory servers.


    JMeter Sampler And its types with Examples | EngineerDiaries

    8.Mail Reader Sampler 

    To read the emails also Jmeter has a provision. Don't use think JMeter is killing it !!! You can read the mail using POP3 And IMAP protocols here. POP3 downloads the email from the mail server to the disk whereas IMAP stores the messages on the server and sync them across multiple devices. With Jmeter Mail Reader you need to provide the hostname, credentials, and also the folder to read like inbox, outbox, etc. Now when load testing it, then put it under a controller with loop and thread group of multiple users to handle the mail requests.


    JMeter Sampler And its types with Examples | EngineerDiaries

    9. OS Process Request

    How do you interact with the operating system? Using command line right. Even that request can be sent via Jmeter. The simple basic request of cd C:/test is done via command CD and the parameters as parameter 1: /C  parameter 2: cd parameter 3: C:/test. Now load testing the operating system level request would be more about testing the efficiency of the operating system. Its capacity to take in, so that when an application slows down it can be deployed on a better configuration system as load taking capacity of this one isn't sufficient. That is how you be sure of.


    JMeter Sampler And its types with Examples | EngineerDiaries

    10. TCP Request

    TCP sampler opens up TCP/IP connection to the server. TCP requests are used to detect the loss of data while connection establishment and minimize network congestion. So TCP is part of the transport layer that is data gets divided into chunks and then is received at the server end. Whereas HTTP is more about Client-Server connection requests. With TCP sampler is more on the accuracy of data, while HTTP is about establishing a connection. 


    JMeter Sampler And its types with Examples | EngineerDiaries

    Comments Section: