A connection to Apache Pulsar is an expensive operation, reason why it is recommended to create a single instance per application.

The main constructor returns a cats.effect.Resource, and is defined as follows.

import cats.effect._
import dev.profunktor.pulsar.Config.PulsarURL
import dev.profunktor.pulsar.Pulsar.Settings

import org.apache.pulsar.client.api.{ PulsarClient => Underlying }

type T = Underlying

def make[F[_]: Sync](
    url: PulsarURL,
    settings: Settings = Settings()
): Resource[F, T] = ???

A PulsarURL can only be built using smart builders, as shown in the next section.


A default configuration is usually enough to get started locally.

import dev.profunktor.pulsar.Config

val config = Config.Builder.default

It sets tenant=public, namespace=default, and url=pulsar://localhost:6650. If would like to change any of these values, you can use the configuration builder. E.g.

val custom: Config =

Pulsar client

Once we have a configuration, we can proceed with the creation of a Pulsar client, necessary to create consumers, producers, and so on.

import dev.profunktor.pulsar._


Connection settings

Via the second constructor argument, we can set a few client options, such as timeouts.

import scala.concurrent.duration._

val settings =

Pulsar.make[IO](config.url, settings)

To learn more about transactions, check out the Transactions section.