Search in sources :

Example 26 with ZeebeClientBuilder

use of io.camunda.zeebe.client.ZeebeClientBuilder in project zeebe by camunda-cloud.

the class ClusteringRule method createClient.

private ZeebeClient createClient() {
    final String contactPoint = NetUtil.toSocketAddressString(gateway.getGatewayCfg().getNetwork().toSocketAddress());
    final ZeebeClientBuilder zeebeClientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(contactPoint);
    clientConfigurator.accept(zeebeClientBuilder);
    final ZeebeClient client = zeebeClientBuilder.build();
    closeables.manage(client);
    return client;
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder)

Example 27 with ZeebeClientBuilder

use of io.camunda.zeebe.client.ZeebeClientBuilder in project zeebe by camunda-cloud.

the class Ipv6IntegrationTest method shouldCommunicateOverIpv6.

@Test
public void shouldCommunicateOverIpv6() {
    // given
    containers.parallelStream().forEach(GenericContainer::start);
    gateway.start();
    // when
    final ZeebeClientBuilder zeebeClientBuilder = ZeebeClient.newClientBuilder().usePlaintext().gatewayAddress(gateway.getExternalGatewayAddress());
    try (final var client = zeebeClientBuilder.build()) {
        final Topology topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
        // then - can find each other
        TopologyAssert.assertThat(topology).isComplete(3, 1);
    }
}
Also used : ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder) Topology(io.camunda.zeebe.client.api.response.Topology) GenericContainer(org.testcontainers.containers.GenericContainer) Test(org.junit.jupiter.api.Test)

Example 28 with ZeebeClientBuilder

use of io.camunda.zeebe.client.ZeebeClientBuilder in project zeebe by camunda-cloud.

the class GrpcClientRule method before.

@Override
public void before() {
    startTime = System.currentTimeMillis();
    final ZeebeClientBuilder builder = ZeebeClient.newClientBuilder().defaultRequestTimeout(Duration.ofSeconds(10));
    configurator.accept(builder);
    client = builder.build();
    LOG.info("\n====\nClient startup time: {}\n====\n", (System.currentTimeMillis() - startTime));
    startTime = System.currentTimeMillis();
}
Also used : ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder)

Example 29 with ZeebeClientBuilder

use of io.camunda.zeebe.client.ZeebeClientBuilder in project zeebe by camunda-cloud.

the class JobWorkerCreator method main.

public static void main(final String[] args) {
    final String defaultAddress = "localhost:26500";
    final String envVarAddress = System.getenv("ZEEBE_ADDRESS");
    final ZeebeClientBuilder clientBuilder;
    if (envVarAddress != null) {
        /* Connect to Camunda Cloud Cluster, assumes that credentials are set in environment variables.
       * See JavaDoc on class level for details
       */
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(envVarAddress);
    } else {
        // connect to local deployment; assumes that authentication is disabled
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(defaultAddress).usePlaintext();
    }
    final String jobType = "foo";
    try (final ZeebeClient client = clientBuilder.build()) {
        System.out.println("Opening job worker.");
        try (final JobWorker workerRegistration = client.newWorker().jobType(jobType).handler(new ExampleJobHandler()).timeout(Duration.ofSeconds(10)).open()) {
            System.out.println("Job worker opened and receiving jobs.");
            // run until System.in receives exit command
            waitUntilSystemInput("exit");
        }
    }
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder) JobWorker(io.camunda.zeebe.client.api.worker.JobWorker)

Example 30 with ZeebeClientBuilder

use of io.camunda.zeebe.client.ZeebeClientBuilder in project zeebe by camunda-cloud.

the class NonBlockingProcessInstanceCreator method main.

public static void main(final String[] args) {
    final String defaultAddress = "localhost:26500";
    final String envVarAddress = System.getenv("ZEEBE_ADDRESS");
    final ZeebeClientBuilder clientBuilder;
    if (envVarAddress != null) {
        /* Connect to Camunda Cloud Cluster, assumes that credentials are set in environment variables.
       * See JavaDoc on class level for details
       */
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(envVarAddress);
    } else {
        // connect to local deployment; assumes that authentication is disabled
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(defaultAddress).usePlaintext();
    }
    final int numberOfInstances = 100_000;
    final String bpmnProcessId = "demoProcess";
    try (final ZeebeClient client = clientBuilder.build()) {
        System.out.println("Creating " + numberOfInstances + " process instances");
        final long startTime = System.currentTimeMillis();
        long instancesCreating = 0;
        while (instancesCreating < numberOfInstances) {
            // this is non-blocking/async => returns a future
            final ZeebeFuture<ProcessInstanceEvent> future = client.newCreateInstanceCommand().bpmnProcessId(bpmnProcessId).latestVersion().send();
            // could put the future somewhere and eventually wait for its completion
            instancesCreating++;
        }
        // creating one more instance; joining on this future ensures
        // that all the other create commands were handled
        client.newCreateInstanceCommand().bpmnProcessId(bpmnProcessId).latestVersion().send().join();
        System.out.println("Took: " + (System.currentTimeMillis() - startTime));
    }
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent)

Aggregations

ZeebeClientBuilder (io.camunda.zeebe.client.ZeebeClientBuilder)40 ZeebeClient (io.camunda.zeebe.client.ZeebeClient)24 ProcessInstanceEvent (io.camunda.zeebe.client.api.response.ProcessInstanceEvent)6 Topology (io.camunda.zeebe.client.api.response.Topology)6 RaftPartition (io.atomix.raft.partition.RaftPartition)3 DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)3 ProcessInstanceResult (io.camunda.zeebe.client.api.response.ProcessInstanceResult)3 JobWorker (io.camunda.zeebe.client.api.worker.JobWorker)3 WorkerCfg (io.camunda.zeebe.config.WorkerCfg)3 Before (org.junit.Before)3 Test (org.junit.jupiter.api.Test)3 GenericContainer (org.testcontainers.containers.GenericContainer)3