Course Setup
Use Case
Messaging Basics
Consumer Subscription Types
API Internals for Message Integrity and Scaling
1 of 3

Tutorial: Code Helpers: PulsarClientFactory, AsyncRunner and MessageGenerator

We have learned how to create a client synchronously, create a producer synchronously, and publish a message to the cluster synchronously.

For the rest of the course, we will be working mostly with asynchronous code.  We will also be using some helper classes for repeated code.  In the following video we will learn about:

  1. AsyncRunner.java to help us with boilerplate asynchronous code
  2. PulsarClientFactory.java for connecting to the cluster
  3. MessageGenerator.java for creating test messages for our e-commerce application

The following Java files are used throughout the rest of the course to help us write our application:

PulsarClientFactory.java:

  • handles creating the client
  • be sure to update the path to your credentials file

MessageGenerator.java:

  • create String or other message types to publish to the server

AsyncRunner.java:

  • creates an asynchronous framework for our application
  • the PulsarClient is automatically created for us by the run() method
  • we must write the abstract setup(PulsarClient client) and abstract workLoop()