Share this page

# Record a Kafka script

You can record a Kafka protocol script in VuGen to monitor the health of your Kafka deployment.

In this topic:

## Record a Kafka script

Configure the necessary settings and record a Kafka protocol script in VuGen.

To record a Kafka script:

1. Prerequisites:

   - Before working with Kafka scripts, make sure your Java environment is set up. For details, see Set up the Java environment.
   - You must have a working Kafka broker.
   - You must have a configuration file in VuGen for the Kafka consumer, containing the mandatory configuration properties. If you have not created or imported a configuration file in VuGen, see Consumer configuration.

2. In VuGen, create a new Kafka protocol script. The Kafka script template opens in the VuGen editor.

3. (Optional) Set the code generation options for the script, using the Kafka > Code Generation node of the recording options:

   1. Choose where the producer configuration code is saved. By default, the producer configuration code is saved in the script file.

      Note: After you record the script, you need to locate the producer configuration code and modify it in order to replay the script.

   2. Enable VuGen to insert a consumer instance at the end of the script, if relevant. This consumer's purpose is to poll for all records sent by the producer during replay. This consumer can also be set to commit these records. If the records are committed, they are not consumed again by any subsequent consumers that poll for records.

4. Click the Record button in the VuGen toolbar. The Start Recording dialog box opens.

5. In the Configuration dropdown, select the configuration file for the consumer.

6. In the Topics field, add the Kafka topics to which the consumer subscribes.

7. Click Start Recording and record the script.

8. After you finish recording, modify the producer configuration. For details, see Producer configuration.

Back to top

## Producer and consumer configuration

VuGen's Kafka protocol provides an encapsulated producer and consumer per Vuser. The producer and consumer configurations are each set at different stages of recording the script.

Consumer configuration

The consumer is configured based on a configuration file that you create and select before you begin recording. You must include certain properties in the configuration file to record a script. Consumer configuration files created or imported in VuGen are saved, and can be reused for later Kafka recordings.

To create a configuration file:

1. Open a Kafka script.
2. In the VuGen toolbar, select Record > Recording Options.
3. Use the Kafka > Configuration Files node of the recording options to create a configuration file. For details, see Kafka > Configuration Files.

Producer configuration

When you record a script, the producer is configured automatically based on shared properties copied from the consumer configuration. After you finish recording, you modify the producer configuration to define certain mandatory properties. You must define these properties for the producer in order to replay the script. You can also add or modify other properties as needed.

You can modify the producer configuration in two ways:

- Insert the LrKafkaProducer.reconfigureProducer API into the recorded script. For details, see Kafka Functions in the Function Reference.

- Manually edit the code that defines the producer configuration. By default, this code is located in the recorded Kafka script. However, depending on the code generation settings used when the script was recorded, the code may be located in a .properties file saved in the same folder as the script.

For details on the mandatory properties, shared properties, and other properties available for producer and consumer configuration, see Kafka consumer and producer properties.

Back to top

See also:

- Kafka protocol
- Kafka recording options
- Record a Vuser script
- Start Recording dialog box

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 26.1 All View Local Help Center View Online Help Center Version: