Search in sources :

Example 11 with ZeebeClientBuilder

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

the class ProcessInstanceWithResultCreator 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 bpmnProcessId = "demoProcessSingleTask";
    try (final ZeebeClient client = clientBuilder.build()) {
        // open job workers so that task are executed and process is completed
        openJobWorker(client);
        System.out.println("Creating process instance");
        final ProcessInstanceResult processInstanceResult = client.newCreateInstanceCommand().bpmnProcessId(bpmnProcessId).latestVersion().withResult().send().join();
        System.out.println("Process instance created with key: " + processInstanceResult.getProcessInstanceKey() + " and completed with results: " + processInstanceResult.getVariables());
    }
}
Also used : ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder)

Example 12 with ZeebeClientBuilder

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

the class TopologyViewer method main.

public static void main(final String[] args) {
    final String defaultAddress = "localhost:26500";
    final String envVarAddress = System.getenv("ZEEBE_ADDRESS");
    final ZeebeClientBuilder clientBuilder;
    final String contactPoint;
    if (envVarAddress != null) {
        /* Connect to Camunda Cloud Cluster, assumes that credentials are set in environment variables.
       * See JavaDoc on class level for details
       */
        contactPoint = envVarAddress;
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(envVarAddress);
    } else {
        // connect to local deployment; assumes that authentication is disabled
        contactPoint = defaultAddress;
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(defaultAddress).usePlaintext();
    }
    try (final ZeebeClient client = clientBuilder.build()) {
        System.out.println("Requesting topology with initial contact point " + contactPoint);
        final Topology topology = client.newTopologyRequest().send().join();
        System.out.println("Topology:");
        topology.getBrokers().forEach(b -> {
            System.out.println("    " + b.getAddress());
            b.getPartitions().forEach(p -> System.out.println("      " + p.getPartitionId() + " - " + p.getRole()));
        });
        System.out.println("Done.");
    }
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder) Topology(io.camunda.zeebe.client.api.response.Topology)

Example 13 with ZeebeClientBuilder

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

the class HandleVariablesAsPojo 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();
    }
    try (final ZeebeClient client = clientBuilder.build()) {
        final Order order = new Order();
        order.setOrderId(31243);
        client.newCreateInstanceCommand().bpmnProcessId("demoProcess").latestVersion().variables(order).send().join();
        client.newWorker().jobType("foo").handler(new DemoJobHandler()).open();
        // run until System.in receives exit command
        waitUntilSystemInput("exit");
    }
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder)

Example 14 with ZeebeClientBuilder

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

the class ProcessDeployer 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();
    }
    try (final ZeebeClient client = clientBuilder.build()) {
        final DeploymentEvent deploymentEvent = client.newDeployResourceCommand().addResourceFromClasspath("demoProcess.bpmn").send().join();
        System.out.println("Deployment created with key: " + deploymentEvent.getKey());
    }
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder) DeploymentEvent(io.camunda.zeebe.client.api.response.DeploymentEvent)

Example 15 with ZeebeClientBuilder

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

the class ProcessInstanceCreator 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 bpmnProcessId = "demoProcess";
    try (final ZeebeClient client = clientBuilder.build()) {
        System.out.println("Creating process instance");
        final ProcessInstanceEvent processInstanceEvent = client.newCreateInstanceCommand().bpmnProcessId(bpmnProcessId).latestVersion().send().join();
        System.out.println("Process instance created with key: " + processInstanceEvent.getProcessInstanceKey());
    }
}
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