Clients
Client Creation
An Infinitic client lets us start, retry and cancel tasks or workflows, usually from our Web App controllers.
First, add the infinitic-client
dependency into our build.gradle build.gradle.kts file:
dependencies {
...
implementation "io.infinitic:infinitic-client:0.15.0"
...
}
dependencies {
...
implementation("io.infinitic:infinitic-client:0.15.0")
...
}
We can then instantiate a client from a configuration file in the file system:
import io.infinitic.clients.InfiniticClient;
...
InfiniticClient client = InfiniticClient.fromConfigFile("infinitic.yml");
import io.infinitic.clients.InfiniticClient
...
val client = InfiniticClient.fromConfigFile("infinitic.yml")
or in the resource folder:
import io.infinitic.clients.InfiniticClient;
...
InfiniticClient client = InfiniticClient.fromConfigResource("/infinitic.yml");
import io.infinitic.clients.InfiniticClient
...
val client = InfiniticClient.fromConfigResource("/infinitic.yml")
The infinitic.yml configuration file should contain:
name
(optional): Specifies the name of the clientpulsar
: Details the connection parameters for PulsarshutdownGracePeriodInSeconds
(optional): Defines the grace period allotted to the client to complete its current actions before shutting down (default is10.0
seconds).
# optional
name: client_name
pulsar:
brokerServiceUrl: pulsar://localhost:6650
webServiceUrl: http://localhost:8080
tenant: infinitic
namespace: dev
...
# optional
shutdownGracePeriodInSeconds: 10.0
When specifying a name in the infinitic.yml
configuration file, it must be unique among all clients connected to Pulsar. This name will be utilized as the Pulsar producer name, ensuring distinct identification within Pulsar.